Skip to content

Commit 6c15719

Browse files
committed
fix: missing file error when --watch used without argument
1 parent 56aba88 commit 6c15719

2 files changed

Lines changed: 14 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
@@ -32,6 +32,11 @@ const { once } = require('events');
3232
prepareMainThreadExecution(false, false);
3333
markBootstrapComplete();
3434

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

0 commit comments

Comments
 (0)