Skip to content

Commit

Permalink
debugger: apply automatic lint fixes for inspect_repl.js
Browse files Browse the repository at this point in the history
For issues that ESLint can fix automatically, fix them.

PR-URL: #38411
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
Trott committed Apr 28, 2021
1 parent ea47bd2 commit bdb6c59
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/internal/inspector/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ function createRepl(inspector) {
})
.join('\n');
}

function listScripts(displayNatives = false) {
print(formatScripts(displayNatives));
}
Expand Down Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -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])})`;
Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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)}`;
}
Expand All @@ -829,17 +830,15 @@ 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 };
}
});

Profiler.on('consoleProfileFinished', ({ profile }) => {
Profile.createAndRegister({ profile });
print([
'Captured new CPU profile.',
`Access it with profiles[${profiles.length - 1}]`
`Access it with profiles[${profiles.length - 1}]`,
].join('\n'));
});

Expand Down Expand Up @@ -931,22 +930,26 @@ 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();
print(`Wrote snapshot: ${absoluteFile}`);
resolve();
});
}

function onReject(error) {
teardown();
reject(error);
}

function teardown() {
HeapProfiler.removeListener(
'reportHeapSnapshotProgress', onProgress);
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit bdb6c59

Please sign in to comment.