repl: fix tab completion of inspector module

Correctly check for the presence of the inspector module before adding
it to the builtin libs list.

PR-URL: https://github.com/nodejs/node/pull/19505
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Michaël Zasso 2018-03-21 08:17:01 +01:00
parent c6c957d3cc
commit a6f3e8f3fe
2 changed files with 12 additions and 1 deletions

View File

@ -104,7 +104,7 @@ const builtinLibs = [
'stream', 'string_decoder', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib'
];
if (typeof process.binding('inspector').connect === 'function') {
if (typeof process.binding('inspector').open === 'function') {
builtinLibs.push('inspector');
builtinLibs.sort();
}

View File

@ -0,0 +1,11 @@
'use strict';
// Flags: --expose-internals
require('../common');
const assert = require('assert');
const { builtinLibs } = require('internal/modules/cjs/helpers');
const hasInspector = process.config.variables.v8_enable_inspector === 1;
const expectedLibs = hasInspector ? 32 : 31;
assert.strictEqual(builtinLibs.length, expectedLibs);