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
5 changes: 5 additions & 0 deletions lib/internal/main/watch_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
prepareMainThreadExecution(false, false);
markBootstrapComplete();

if (!process.argv[1]) {
process.stderr.write('node: --watch requires specifying a file\n')

Check failure on line 36 in lib/internal/main/watch_mode.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon
process.exit(9);
}

const kKillSignal = convertToValidSignal(getOptionValue('--watch-kill-signal'));
const kShouldFilterModules = getOptionValue('--watch-path').length === 0;
const kEnvFiles = [
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-watch-mode-without-file.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

Check failure on line 1 in test/parallel/test-watch-mode-without-file.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Mandatory module "common" must be loaded before any other modules

Check failure on line 1 in test/parallel/test-watch-mode-without-file.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Mandatory module "common" must be loaded

Check failure on line 1 in test/parallel/test-watch-mode-without-file.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'use strict' is unnecessary inside of modules

import { spawnSync } from 'child_process';
import { strictEqual, match } from "node:assert";

Check failure on line 4 in test/parallel/test-watch-mode-without-file.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Strings must use singlequote

Check failure on line 4 in test/parallel/test-watch-mode-without-file.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Only assign `node:assert` to `assert`

const result = spawnSync(process.execPath, ['--watch'], { encoding: 'utf8' });

strictEqual(result.status, 9);
match(result.stderr, /--watch requires specifying a file/)

Check failure on line 9 in test/parallel/test-watch-mode-without-file.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon
Loading