diff --git a/lib/internal/inspector/inspect_repl.js b/lib/internal/inspector/inspect_repl.js index 82e97a1fce73dd..128ae697105a3d 100644 --- a/lib/internal/inspector/inspect_repl.js +++ b/lib/internal/inspector/inspect_repl.js @@ -353,6 +353,7 @@ function createRepl(inspector) { }) .join('\n'); } + function listScripts(displayNatives = false) { print(formatScripts(displayNatives)); } @@ -402,9 +403,9 @@ function createRepl(inspector) { const i = start + offset; const isCurrent = i === (lineNumber + 1); - const markedLine = isCurrent - ? markSourceColumn(lineText, columnNumber, options.colors) - : lineText; + const markedLine = isCurrent ? + markSourceColumn(lineText, columnNumber, options.colors) : + lineText; let isBreakpoint = false; knownBreakpoints.forEach(({ location }) => { @@ -488,7 +489,7 @@ function createRepl(inspector) { function prepareControlCode(input) { if (input === '\n') return lastCommand; - // exec process.title => exec("process.title"); + // Add parentheses: exec process.title => exec("process.title"); const match = input.match(/^\s*exec\s+([^\n]*)/); if (match) { lastCommand = `exec(${JSON.stringify(match[1])})`; @@ -678,13 +679,13 @@ function createRepl(inspector) { // setBreakpoint('fn()'): Break when a function is called if (script.endsWith('()')) { const debugExpr = `debug(${script.slice(0, -2)})`; - const debugCall = selectedFrame - ? Debugger.evaluateOnCallFrame({ + const debugCall = selectedFrame ? + Debugger.evaluateOnCallFrame({ callFrameId: selectedFrame.callFrameId, expression: debugExpr, includeCommandLineAPI: true, - }) - : Runtime.evaluate({ + }) : + Runtime.evaluate({ expression: debugExpr, includeCommandLineAPI: true, }); @@ -807,7 +808,7 @@ function createRepl(inspector) { inspector.suspendReplWhile(() => Promise.all([formatWatchers(true), selectedFrame.list(2)]) - .then(([watcherList, context]) => { + .then(({ 0: watcherList, 1: context }) => { if (watcherList) { return `${watcherList}\n${inspect(context)}`; } @@ -829,9 +830,7 @@ function createRepl(inspector) { Debugger.on('scriptParsed', (script) => { const { scriptId, url } = script; if (url) { - knownScripts[scriptId] = Object.assign({ - isNative: isNativeUrl(url), - }, script); + knownScripts[scriptId] = { isNative: isNativeUrl(url), ...script }; } }); @@ -839,7 +838,7 @@ function createRepl(inspector) { Profile.createAndRegister({ profile }); print([ 'Captured new CPU profile.', - `Access it with profiles[${profiles.length - 1}]` + `Access it with profiles[${profiles.length - 1}]`, ].join('\n')); }); @@ -931,11 +930,13 @@ function createRepl(inspector) { print(`Heap snapshot: ${done}/${total}`, false); } } + function onChunk({ chunk }) { sizeWritten += chunk.length; writer.write(chunk); print(`Writing snapshot: ${sizeWritten}`, false); } + function onResolve() { writer.end(() => { teardown(); @@ -943,10 +944,12 @@ function createRepl(inspector) { resolve(); }); } + function onReject(error) { teardown(); reject(error); } + function teardown() { HeapProfiler.removeListener( 'reportHeapSnapshotProgress', onProgress); @@ -1071,7 +1074,7 @@ function createRepl(inspector) { .then(() => Debugger.setBlackboxPatterns({ patterns: [] })) .then(() => Debugger.setPauseOnExceptions({ state: pauseOnExceptionState })) .then(() => restoreBreakpoints()) - .then(() => Runtime.runIfWaitingForDebugger()) + .then(() => Runtime.runIfWaitingForDebugger()); } return function startRepl() {