diff --git a/src/__tests__/core/fileSystemWatcher.test.ts b/src/__tests__/core/fileSystemWatcher.test.ts index 988d7ba2b3a..60e05f7b553 100644 --- a/src/__tests__/core/fileSystemWatcher.test.ts +++ b/src/__tests__/core/fileSystemWatcher.test.ts @@ -246,8 +246,9 @@ describe('isValidWatchRoot()', () => { it('should check valid root', async () => { expect(isValidWatchRoot('/')).toBe(false) expect(isValidWatchRoot(os.homedir())).toBe(false) - expect(isValidWatchRoot('/tmp/a/b/c')).toBe(false) expect(isValidWatchRoot(os.tmpdir())).toBe(false) + expect(isValidWatchRoot('/tmp/a')).toBe(true) + expect(isValidWatchRoot('/tmp/a/b/c')).toBe(true) }) }) diff --git a/src/core/watchman.ts b/src/core/watchman.ts index 1a9f1eb0cda..6eac0e925ec 100644 --- a/src/core/watchman.ts +++ b/src/core/watchman.ts @@ -171,13 +171,11 @@ export default class Watchman { } /** - * Exclude user's home, driver, tmpdir + * Exclude root, user's home, driver and tmpdir, but allow sub-directories under them. */ export function isValidWatchRoot(root: string): boolean { - if (root == '/' || root == '/tmp' || root == '/private/tmp') return false + if (root == '/' || root == '/tmp' || root == '/private/tmp' || root == os.tmpdir()) return false if (isParentFolder(root, os.homedir(), true)) return false if (path.parse(root).base == root) return false - if (root.startsWith('/tmp/') || root.startsWith('/private/tmp/')) return false - if (isParentFolder(os.tmpdir(), root, true)) return false return true }