-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
debugger: add --help to node inspect and improve docs
#63201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Tests that --help / -h are forwarded to the debuggee when a script is | ||
| // also passed, instead of being hijacked as the inspect help flag. | ||
|
|
||
| import { skipIfInspectorDisabled } from '../common/index.mjs'; | ||
|
|
||
| skipIfInspectorDisabled(); | ||
|
|
||
| import * as fixtures from '../common/fixtures.mjs'; | ||
| import startCLI from '../common/debugger.js'; | ||
|
|
||
| import assert from 'assert'; | ||
|
|
||
| async function getEvaluatedArgv(flag) { | ||
| const script = fixtures.path('debugger', 'empty.js'); | ||
| const cli = startCLI([script, flag]); | ||
| try { | ||
| await cli.waitForInitialBreak(); | ||
| await cli.waitForPrompt(); | ||
| await cli.command('exec process.argv'); | ||
| return cli.output; | ||
| } finally { | ||
| await cli.quit(); | ||
| } | ||
| } | ||
|
|
||
| async function checkForwardedHelp(flag) { | ||
| const output = await getEvaluatedArgv(flag); | ||
| assert(output.includes(`'${flag}'`), | ||
| `expected debuggee process.argv to include "${flag}", got:\n${output}`); | ||
| assert.doesNotMatch(output, /Usage: .+ inspect/); | ||
| } | ||
|
|
||
| await checkForwardedHelp('--help'); | ||
| await checkForwardedHelp('-h'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| 'use strict'; | ||
|
|
||
| // Tests that `node inspect` help text is printed when | ||
| // `--help` / `-h` is passed and there is no script, | ||
| // or when there are no additional arguments. | ||
| const common = require('../common'); | ||
| common.skipIfInspectorDisabled(); | ||
|
|
||
| const { | ||
| spawnSyncAndAssert, | ||
| spawnSyncAndExit, | ||
| } = require('../common/child_process'); | ||
|
|
||
| const usageRegex = /^Usage: .+ inspect .*debugger\.html/ms; | ||
|
|
||
| // --help / -h prints the usage to stdout and exits with code 0, | ||
| // for both interactive and probe-mode invocations. | ||
| const helpArgs = [ | ||
| ['inspect', '--help'], | ||
| ['inspect', '-h'], | ||
| ['inspect', '--probe', '--help'], | ||
| ['inspect', '--probe', '-h'], | ||
| ]; | ||
|
|
||
| for (const args of helpArgs) { | ||
| spawnSyncAndAssert(process.execPath, args, { | ||
| stdout: usageRegex, | ||
| }); | ||
| } | ||
|
|
||
| // `node inspect` with no args prints the usage to stderr and exits | ||
| // with kInvalidCommandLineArgument (9). | ||
| spawnSyncAndExit(process.execPath, ['inspect'], { | ||
| status: 9, | ||
| signal: null, | ||
| stderr: usageRegex, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.