Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugger: fix auto-fixable lint issues in inspect library code #38411

Merged
merged 2 commits into from
Apr 28, 2021
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
6 changes: 3 additions & 3 deletions lib/internal/inspector/_inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ class NodeInspector {

print(text, appendNewline = false) {
this.clearLine();
this.stdout.write(appendNewline ? `${text}\n` : text);
this.stdout.write(appendNewline ? `${text}\n` : text);
}

#stdioBuffers = {stdout: '', stderr: ''};
#stdioBuffers = { stdout: '', stderr: '' };
childPrint(text, which) {
const lines = (this.#stdioBuffers[which] + text)
.split(/\r\n|\r|\n/g);
Expand All @@ -283,7 +283,7 @@ class NodeInspector {
this.repl.displayPrompt(true);
}
}

if (textToPrint.endsWith('Waiting for the debugger to disconnect...\n')) {
this.killChild();
}
Expand Down
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