From ee4390a167a72b3199e184546ece181cc426317a 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/module.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/module.js b/lib/internal/module.js index d2140411552429..0bb1cea4050e16 100644 --- a/lib/internal/module.js +++ b/lib/internal/module.js @@ -89,7 +89,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 00000000000000..5407464d57942d --- /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/module'); + +const hasInspector = process.config.variables.v8_enable_inspector === 1; + +const expectedLibs = hasInspector ? 32 : 31; +assert.strictEqual(builtinLibs.length, expectedLibs);