node/test/parallel/test-debugger-probe-missing-expr.js
Joyee Cheung 141de35399
debugger: add --help to node inspect and improve docs
- Add `--help` / `-h` to `node inspect` covering both interactive and
  non-interactive probe modes. The help text is printed when
  `--help`/`-h` appears before any positional argument to avoid
  hijacking `--help` passed to a child script.
- Improve the documentation of probe mode and add examples, explain
  same-location probe coalescing, TDZ caveat for let/const bindings,
  basename matching and exit code behavior. Also move it to a
  section parallel to interactive mode. Remove recommendation of
  evaluating structured expressions as that is prone to missing
  info in JSON mode.

Drive-by: When probe mode exits due to invalid arguments, exit with
`kInvalidCommandLineArgument` (9) instead of `kGenericUserError` (1).

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63201
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-06-18 00:15:51 +02:00

19 lines
505 B
JavaScript

// This tests that probe mode rejects a --probe without a matching --expr.
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const { spawnSyncAndExit } = require('../common/child_process');
const { probeScript } = require('../common/debugger-probe');
spawnSyncAndExit(process.execPath, [
'inspect',
'--probe', `${probeScript}:12`,
probeScript,
], {
signal: null,
status: 9,
stderr: /Each --probe must be followed immediately by --expr/,
trim: true,
});