mirror of
https://github.com/nodejs/node.git
synced 2025-05-19 18:25:59 +00:00

Instead of `process.config.variables.v8_enable_inspector` which depends on the variable name in gyp files, or detecting `internalBinding('inspector').Connection`. PR-URL: https://github.com/nodejs/node/pull/25291 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
26 lines
500 B
JavaScript
26 lines
500 B
JavaScript
'use strict';
|
|
|
|
const { hasInspector } = internalBinding('config');
|
|
const inspector = hasInspector ? require('inspector') : undefined;
|
|
|
|
let session;
|
|
|
|
function sendInspectorCommand(cb, onError) {
|
|
if (!hasInspector) return onError();
|
|
if (session === undefined) session = new inspector.Session();
|
|
try {
|
|
session.connect();
|
|
try {
|
|
return cb(session);
|
|
} finally {
|
|
session.disconnect();
|
|
}
|
|
} catch {
|
|
return onError();
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
sendInspectorCommand
|
|
};
|