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: nodejs#38411
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
Trott authored and aduh95 committed Jul 19, 2021
1 parent 62eec10 commit 0384dd4
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 @@ -331,6 +331,7 @@ function createRepl(inspector) {
})
.join('\n');
}

function listScripts(displayNatives = false) {
print(formatScripts(displayNatives));
}
Expand Down Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -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])})`;
Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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)}`;
}
Expand All @@ -807,17 +808,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 @@ -909,22 +908,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 @@ -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() {
Expand Down

0 comments on commit 0384dd4

Please sign in to comment.