Skip to content

Commit f206782

Browse files
watch: fix missing file error when --watch used without argument
Signed-off-by: anshikakalpana <anshikajain196872@gmail.com>
1 parent 1434a07 commit f206782

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/internal/main/watch_mode.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const { once } = require('events');
3131
prepareMainThreadExecution(false, false);
3232
markBootstrapComplete();
3333

34+
if (!process.argv[1]) {
35+
process.stderr.write('node: --watch requires specifying a file\n');
36+
process.exit(9);
37+
}
38+
3439
const kKillSignal = convertToValidSignal(getOptionValue('--watch-kill-signal'));
3540
const kShouldFilterModules = getOptionValue('--watch-path').length === 0;
3641
const kEnvFiles = getOptionValue('--env-file');
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import '../common/index.mjs';
2+
import { spawnSync } from 'node:child_process';
3+
import assert from 'node:assert';
4+
5+
const result = spawnSync(process.execPath, ['--watch'], { encoding: 'utf8' });
6+
assert.strictEqual(result.status, 9);
7+
assert.match(result.stderr, /--watch requires specifying a file/);

0 commit comments

Comments
 (0)