Uh oh!
There was an error while loading. Please reload this page.
watch: fix watch path with equals - #47369
Conversation
910d539 to
2d84c7bCompareUh oh!
There was an error while loading. Please reload this page.
debadree25
left a comment
There was a problem hiding this comment.
Is there was no general test for —watch-path both the tests for checking for non-existing files, if there isn't i think we could add a test for —watch-path watching over a directory and executing a file like it is for the —watch tests
MoLow
commented
Apr 2, 2023
There is such a test. see |
2d84c7b to
5c04888Compare
could you point out which ones 😅😅 on both of which mention watching non-existing case |
debadree25
commented
Apr 2, 2023
I was basically talking of a test something like this it('should watch changes to a file with watch-path',{skip: !supportsRecursive,},async()=>{constfile=createTmpFile();constwatchedFile=fixtures.path('watch-mode/subdir/file.js');const{ stderr, stdout }=awaitspawnWithRestarts({
file,
watchedFile,args: ['--watch-path',fixtures.path('./watch-mode/subdir'),file],});assert.strictEqual(stderr,'');assertRestartedCorrectly({
stdout,messages: {inner: 'running',completed: `Completed running ${inspect(file)}`,restarted: `Restarting ${inspect(file)}`},});}); |
debadree25
commented
Apr 2, 2023
ok was able make the test case pass with the following changes: in --- a/lib/internal/main/watch_mode.js+++ b/lib/internal/main/watch_mode.js@@ -53,7 +53,7 @@ let exited;
function start() {
exited = false;
- const stdio = kShouldFilterModules ? ['inherit', 'inherit', 'inherit', 'ipc'] : undefined;+ const stdio = kShouldFilterModules ? ['inherit', 'inherit', 'inherit', 'ipc'] : 'inherit';
child = spawn(process.execPath, args, { stdio, env: { ...process.env, WATCH_REPORT_DEPENDENCIES: '1' } });
watcher.watchChildProcessModules(child);
child.once('exit', (code) => {and updated the tests as follows: --- a/test/sequential/test-watch-mode.mjs+++ b/test/sequential/test-watch-mode.mjs@@ -148,7 +165,8 @@ describe('watch mode', { concurrency: false, timeout: 60_000 }, () => {
args: ['--watch-path', fixtures.path('./watch-mode/subdir/'), file],
});
- assert.strictEqual(stderr, '');+ assert.match(stderr, /Error: Cannot find module/);+ assert(stderr.match(/Error: Cannot find module/g).length >= 2);
assertRestartedCorrectly({
stdout,
messages: { completed: `Failed running ${inspect(file)}`, restarted: `Restarting ${inspect(file)}` },
@@ -166,7 +184,8 @@ describe('watch mode', { concurrency: false, timeout: 60_000 }, () => {
args: [`--watch-path=${fixtures.path('./watch-mode/subdir/')}`, file],
});
- assert.strictEqual(stderr, '');+ assert.match(stderr, /Error: Cannot find module/);+ assert(stderr.match(/Error: Cannot find module/g).length >= 2);
assertRestartedCorrectly({
stdout,
messages: { completed: `Failed running ${inspect(file)}`, restarted: `Restarting ${inspect(file)}` },does this look ok? if yes could commit it to this branch @MoLow |
5c04888 to
1c4d92cCompareMoLow
commented
Apr 2, 2023
thanks @debadree25! |
debadree25
commented
Apr 2, 2023
just added the test for watch-path in the general case @MoLow |
nodejs-github-bot
commented
Apr 2, 2023
tniessen
left a comment
There was a problem hiding this comment.
FWIW it seems odd to implement this in JS, separate from the usual C++ argument parsing logic. I had similar concerns in the original PR.
debadree25
commented
Apr 2, 2023
Is there a similar example in present cpp where multiple options are parsed like this? |
nodejs-github-bot
commented
Apr 2, 2023
nodejs-github-bot
commented
Apr 2, 2023
nodejs-github-bot
commented
Apr 5, 2023
Landed in 25858e3 |
PR-URL: nodejs#47369Fixes: nodejs#47296 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>

Fixes: #47296
prior to this fix
node --watch-path path.jsworked butnode --watch-path=path.jsdid not