From 94f0cadea3ddb3467f6e5a8628d8ecd1766b31b8 Mon Sep 17 00:00:00 2001 From: Luke Page <137174537+lukpsaxo@users.noreply.github.com> Date: Wed, 19 Jun 2024 20:14:10 +0200 Subject: [PATCH] fix(fs-watcher) ignore node_modules on windows (#31341) Partially fixes https://github.com/microsoft/playwright/issues/31337 by supporting ignoring node_modules on windows. When I debug the function it gets a unix style path filename on windows, so the function never ignores node_modules. The ignore path globs are expected to use the unix path seperator and I've tested this fix works on windows and I assume that since mac uses unix style, it also works there (this is a pretty standard glob construct (chokidar points at any match https://github.com/micromatch/anymatch and anymatch has this exact example in their readme.md) Signed-off-by: Luke Page <137174537+lukpsaxo@users.noreply.github.com> --- packages/playwright/src/fsWatcher.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/playwright/src/fsWatcher.ts b/packages/playwright/src/fsWatcher.ts index c0d4e4d04e..a1c09c343d 100644 --- a/packages/playwright/src/fsWatcher.ts +++ b/packages/playwright/src/fsWatcher.ts @@ -16,7 +16,6 @@ import { chokidar } from './utilsBundle'; import type { FSWatcher } from 'chokidar'; -import path from 'path'; export type FSEvent = { event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', file: string }; @@ -52,7 +51,7 @@ export class Watcher { if (!this._watchedFiles.length) return; - const ignored = [...this._ignoredFolders, (name: string) => name.includes(path.sep + 'node_modules' + path.sep)]; + const ignored = [...this._ignoredFolders, '**/node_modules/**']; this._fsWatcher = chokidar.watch(watchedFiles, { ignoreInitial: true, ignored }).on('all', async (event, file) => { if (this._throttleTimer) clearTimeout(this._throttleTimer);