From ec76199a0df0301cc7cce2638eae45dc35386bb1 Mon Sep 17 00:00:00 2001 From: David First Date: Wed, 2 Oct 2024 16:04:38 -0400 Subject: [PATCH] fix(watch), avoid watching local-scope files on Windows --- scopes/workspace/watcher/watcher.ts | 3 ++- scripts/establish-dev-link-windows.js | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scopes/workspace/watcher/watcher.ts b/scopes/workspace/watcher/watcher.ts index d42958ecbdde..4fa2a5444fb8 100644 --- a/scopes/workspace/watcher/watcher.ts +++ b/scopes/workspace/watcher/watcher.ts @@ -437,6 +437,7 @@ 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; @@ -444,7 +445,7 @@ export class Watcher { 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, { diff --git a/scripts/establish-dev-link-windows.js b/scripts/establish-dev-link-windows.js index a0e12a141693..7c92069c93d3 100644 --- a/scripts/establish-dev-link-windows.js +++ b/scripts/establish-dev-link-windows.js @@ -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 }); @@ -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;