Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.
Merged
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
8 changes: 8 additions & 0 deletions lib/internal/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,14 @@ function createRepl(inspector) {
}

Debugger.on('paused', ({ callFrames, reason /* , hitBreakpoints */ }) => {
if (process.env.NODE_INSPECT_RESUME_ON_START === '1' &&
reason === 'Break on start') {
debuglog('Paused on start, but NODE_INSPECT_RESUME_ON_START' +
' environment variable is set to 1, resuming');
inspector.client.callMethod('Debugger.resume');
return;
}

// Save execution context's data
currentBacktrace = Backtrace.from(callFrames);
selectedFrame = currentBacktrace[0];
Expand Down
20 changes: 20 additions & 0 deletions test/cli/launch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,23 @@ test('run after quit / restart', (t) => {
.then(() => cli.quit())
.then(null, onFatal);
});

test('auto-resume on start if the environment variable is defined', (t) => {
const script = Path.join('examples', 'break.js');

const cli = startCLI([script], [], {
env: { NODE_INSPECT_RESUME_ON_START: '1' }
});

return cli.waitForInitialBreak()
.then(() => {
t.match(
cli.breakInfo,
{ filename: script, line: 10 },
'skips to the first breakpoint');
})
.then(() => cli.quit())
.then((code) => {
t.equal(code, 0, 'exits with success');
});
});
4 changes: 2 additions & 2 deletions test/cli/start-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function isPreBreak(output) {
return /Break on start/.test(output) && /1 \(function \(exports/.test(output);
}

function startCLI(args, flags = []) {
const child = spawn(process.execPath, [...flags, CLI, ...args]);
function startCLI(args, flags = [], spawnOpts = {}) {
const child = spawn(process.execPath, [...flags, CLI, ...args], spawnOpts);
let isFirstStdoutChunk = true;

const outputBuffer = [];
Expand Down