Skip to content

Commit

Permalink
feat: hook in new argument parser to existing node inspector code
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Jul 29, 2023
1 parent 5ea277f commit fa13bf3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env node --expose-internals -r internal/test/binding --debug-port=0
#!/usr/bin/env node --expose-internals -r internal/test/binding

process.env.NODE_INSPECT_RESUME_ON_START ||= 1;
// process.env.NODE_INSPECT_RESUME_ON_START ||= 1;
// process.env.NODE_INSPECT_PAUSE_ON_EXCEPTION_STATE ||= 'uncaught';

// hijack `require` to load debugger module from this package

const Mod = require('module');
const req = Mod.prototype.require;

Expand Down
5 changes: 3 additions & 2 deletions debugger/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ const {
AbortController,
} = require('internal/abort_controller');

const { 0: InspectClient, 1: createRepl } =
const { 0: InspectClient, 1: createRepl, 2: parseArguments } =
[
require('internal/debugger/inspect_client'),
require('internal/debugger/inspect_repl'),
require('internal/debugger/util/argument_parser'),
];

const debuglog = util.debuglog('inspect');
Expand Down Expand Up @@ -301,7 +302,7 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
process.exit(kInvalidCommandLineArgument);
}

const options = parseArgv(argv);
const options = parseArguments(argv);
const inspector = new NodeInspector(options, stdin, stdout);

stdin.resume();
Expand Down
6 changes: 3 additions & 3 deletions debugger/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ function aliasProperties(target, mapping) {
}

function createRepl(inspector) {
const { Debugger, HeapProfiler, Profiler, Runtime } = inspector;
const { Debugger, HeapProfiler, Profiler, Runtime, options: commandLineOptions } = inspector;

let repl;

Expand All @@ -370,7 +370,7 @@ function createRepl(inspector) {
const watchedExpressions = [];
const knownBreakpoints = [];
let heapSnapshotPromise = null;
let pauseOnExceptionState = process.env.NODE_INSPECT_PAUSE_ON_EXCEPTION_STATE || 'none';
let pauseOnExceptionState = commandLineOptions.pauseOnExceptionState || 'none';
let lastCommand;

// Things we need to reset when the app restarts
Expand Down Expand Up @@ -908,7 +908,7 @@ function createRepl(inspector) {
}

Debugger.on('paused', ({ callFrames, reason, data, asyncStackTrace }) => {
if (process.env.NODE_INSPECT_RESUME_ON_START === '1' &&
if ((process.env.NODE_INSPECT_RESUME_ON_START === '1' || commandLineOptions.inspectResumeOnStart === true) &&
reason === 'Break on start') {
debuglog('Paused on start, but NODE_INSPECT_RESUME_ON_START' +
' environment variable is set to 1, resuming');
Expand Down

0 comments on commit fa13bf3

Please sign in to comment.