Skip to content

Commit 85b98bb

Browse files
committed
test: cover execArgv in watch mode
1 parent 5e1ab9f commit 85b98bb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/sequential/test-watch-mode-watch-flags.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,31 @@ describe('watch mode - watch flags', { concurrency: !process.env.TEST_PARALLEL,
9494
`Completed running ${inspect(file)}. Waiting for file changes before restarting...`,
9595
]);
9696
});
97+
98+
it('exposes watch flags through process.execArgv inside the watched script', async () => {
99+
const projectDir = tmpdir.resolve('project-watch-exec-argv');
100+
mkdirSync(projectDir);
101+
102+
const file = createTmpFile(`
103+
console.log(JSON.stringify(process.execArgv));
104+
`, '.js', projectDir);
105+
const watchPath = path.join(projectDir, 'template.html');
106+
writeFileSync(watchPath, '');
107+
108+
async function assertExecArgv(args, expected) {
109+
const { stdout, stderr } = await runNode({
110+
args, options: { cwd: projectDir }
111+
});
112+
113+
assert.strictEqual(stderr, '');
114+
115+
const execArgvLine = stdout[0];
116+
assert.deepStrictEqual(JSON.parse(execArgvLine), expected);
117+
assert.match(stdout.at(-1), /^Completed running/);
118+
}
119+
120+
await assertExecArgv(['--watch', file], ['--watch']);
121+
await assertExecArgv(['--watch-path=template.html', file], ['--watch-path=template.html']);
122+
await assertExecArgv(['--watch-path', 'template.html', file], ['--watch-path', 'template.html']);
123+
});
97124
});

0 commit comments

Comments
 (0)