Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors,
} else if (test_runner_force_exit) {
errors->push_back("either --watch or --test-force-exit "
"can be used, not both");
} else if (!test_runner && watch_mode_paths.empty() && argv->size() < 1) {
} else if (!test_runner && watch_mode_paths.empty() && argv->size() < 2) {
errors->push_back("--watch requires specifying a file");
}

Expand Down
9 changes: 9 additions & 0 deletions test/sequential/test-watch-mode-watch-flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ async function runNode({
tmpdir.refresh();

describe('watch mode - watch flags', { concurrency: !process.env.TEST_PARALLEL, timeout: 60_000 }, () => {
it('should require a file to watch', async () => {
const { code, signal, stderr, stdout } = await common.spawnPromisified(execPath, ['--watch']);

assert.strictEqual(code, 9);
assert.strictEqual(signal, null);
assert.match(stderr, /--watch requires specifying a file/);
assert.strictEqual(stdout, '');
});

it('when multiple `--watch` flags are provided should run as if only one was', async () => {
const projectDir = tmpdir.resolve('project-multi-flag');
mkdirSync(projectDir);
Expand Down
Loading