diff --git a/lib/internal/inspector/inspect_repl.js b/lib/internal/inspector/inspect_repl.js index 09479cf4b2c88c..5e10dad2e147fd 100644 --- a/lib/internal/inspector/inspect_repl.js +++ b/lib/internal/inspector/inspect_repl.js @@ -331,6 +331,7 @@ function createRepl(inspector) { }) .join('\n'); } + function listScripts(displayNatives = false) { print(formatScripts(displayNatives)); } @@ -380,9 +381,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 }) => { @@ -466,7 +467,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])})`; @@ -656,13 +657,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, }); @@ -785,7 +786,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)}`; } @@ -807,9 +808,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 }; } }); @@ -817,7 +816,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')); }); @@ -909,11 +908,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(); @@ -921,10 +922,12 @@ function createRepl(inspector) { resolve(); }); } + function onReject(error) { teardown(); reject(error); } + function teardown() { HeapProfiler.removeListener( 'reportHeapSnapshotProgress', onProgress); @@ -1049,7 +1052,7 @@ function createRepl(inspector) { .then(() => Debugger.setBlackboxPatterns({ patterns: [] })) .then(() => Debugger.setPauseOnExceptions({ state: pauseOnExceptionState })) .then(() => restoreBreakpoints()) - .then(() => Runtime.runIfWaitingForDebugger()) + .then(() => Runtime.runIfWaitingForDebugger()); } return async function startRepl() {