From a6f3e8f3fe653c48a48c877feec1c24306c3248e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 21 Mar 2018 08:17:01 +0100 Subject: [PATCH] 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 Reviewed-By: Luigi Pinca Reviewed-By: Yuta Hiroto Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell --- lib/internal/modules/cjs/helpers.js | 2 +- test/parallel/test-module-cjs-helpers.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-module-cjs-helpers.js diff --git a/lib/internal/modules/cjs/helpers.js b/lib/internal/modules/cjs/helpers.js index 61565cc5932..fdad580b3b6 100644 --- a/lib/internal/modules/cjs/helpers.js +++ b/lib/internal/modules/cjs/helpers.js @@ -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(); } diff --git a/test/parallel/test-module-cjs-helpers.js b/test/parallel/test-module-cjs-helpers.js new file mode 100644 index 00000000000..1ed9746198a --- /dev/null +++ b/test/parallel/test-module-cjs-helpers.js @@ -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);