Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(watch), avoid watching local-scope files on Windows #9226

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scopes/workspace/watcher/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,15 @@ export class Watcher {
private async createWatcher() {
const usePollingConf = await this.watcherMain.globalConfig.get(CFG_WATCH_USE_POLLING);
const usePolling = usePollingConf === 'true';
const workspacePathLinux = pathNormalizeToLinux(this.workspace.path);
const ignoreLocalScope = (pathToCheck: string) => {
// chokidar 4 doesn't support glob patterns. so we we have to check it with a function.
if (pathToCheck.endsWith('/node_modules')) return true;
// if (pathToCheck.includes('/node_modules/')) return true;
if (pathToCheck.endsWith('/package.json')) return true;
if (pathToCheck.startsWith(this.ipcEventsDir) || pathToCheck.endsWith(UNMERGED_FILENAME)) return false;
return (
pathToCheck.startsWith(`${this.workspace.path}/.git/`) || pathToCheck.startsWith(`${this.workspace.path}/.bit/`)
pathToCheck.startsWith(`${workspacePathLinux}/.git/`) || pathToCheck.startsWith(`${workspacePathLinux}/.bit/`)
);
};
this.fsWatcher = chokidar.watch(this.workspace.path, {
Expand Down
11 changes: 7 additions & 4 deletions scripts/establish-dev-link-windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const userLinkName = process.argv[3];
const linkName = userLinkName || 'bit-dev';

const source = path.join(__dirname, '..', 'bin', 'bit.js');
const dest = `${process.env.localappdata}\\${linkName}`;
const dest = path.join(process.env.localappdata, linkName);

try {
rmSync(dest, { recursive: true });
Expand All @@ -26,9 +26,12 @@ writeFileSync(`${dest}\\${linkName}.bat`, `@echo off\nnode ${source} %*`);

// for git bash.
try {
symlinkSync(source, `${dest}\\${linkName}`);
} catch (err) {}

symlinkSync(source, path.join(dest, linkName));
} catch (err) {
if (err.code === 'EPERM') {
console.log(`permission error: please enable developer mode in windows settings`);
}
}
if (process.env.PATH.includes(dest)) {
console.log(`Success!!!\nNow you can use the "${linkName}" command to run your dev app.`);
return;
Expand Down