From d51a024520d041b04ec2fb14625653d8359f648d Mon Sep 17 00:00:00 2001 From: Harry Brundage Date: Tue, 3 Dec 2024 20:20:50 -0500 Subject: [PATCH] WIP - rwd Tue, Dec 03 08:20 pm [no-changelog-required] --- .../reload-cross-workspace-lazy/test.sh | 1 + .../reload-cross-workspace/test.sh | 2 ++ src/index.ts | 26 ++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/integration-test/reload-cross-workspace-lazy/test.sh b/integration-test/reload-cross-workspace-lazy/test.sh index e0ecbff..3ecba64 100755 --- a/integration-test/reload-cross-workspace-lazy/test.sh +++ b/integration-test/reload-cross-workspace-lazy/test.sh @@ -2,6 +2,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" set -e +export WDS_DEBUG=1 # kill the server when this script exits trap "kill -9 0" INT TERM diff --git a/integration-test/reload-cross-workspace/test.sh b/integration-test/reload-cross-workspace/test.sh index e0ecbff..35f78cb 100755 --- a/integration-test/reload-cross-workspace/test.sh +++ b/integration-test/reload-cross-workspace/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" set -e +export WDS_DEBUG=1 # kill the server when this script exits @@ -14,6 +15,7 @@ pnpm install # make a copy of the run.ts file in the side package for us to modify cp $DIR/side/run.ts $DIR/side/run-scratch.ts + # run a server in the main package in the background $DIR/../../pkg/wds.bin.js $@ --watch --commands $DIR/main/run.ts & diff --git a/src/index.ts b/src/index.ts index 2df130e..c0899a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,16 +71,22 @@ const startFilesystemWatcher = (project: Project) => { ignoreInitial: true, recursive: true, ignore: (filePath: string) => { - if (filePath.includes(nodeModulesDir)) return true; - if (filePath == project.workspaceRoot) return false; - if (filePath == project.config.root) return false; - if (filePath.endsWith(".d.ts")) return true; - if (filePath.endsWith(".map")) return true; - if (filePath.includes(gitDir)) return true; - if (filePath.endsWith(".DS_Store")) return true; - if (filePath.endsWith(".tsbuildinfo")) return true; - - return !project.config.includedMatcher(filePath); + const fn = () => { + if (filePath.includes(nodeModulesDir)) return true; + if (filePath == project.workspaceRoot) return false; + if (filePath == project.config.root) return false; + if (filePath.endsWith(".d.ts")) return true; + if (filePath.endsWith(".map")) return true; + if (filePath.includes(gitDir)) return true; + if (filePath.endsWith(".DS_Store")) return true; + if (filePath.endsWith(".tsbuildinfo")) return true; + + // allow files that match the include glob to be watched, or directories (since they might contain files) + return project.config.includedMatcher(filePath) || !path.extname(filePath); + }; + const result = fn(); + console.error(`${filePath} ignore result`, result); + return result; }, });