| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 59b5e77 commit 582c34d
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - const EventEmitter = require('events'); | ||
| 4 | 3 | const { | |
| 5 | 4 | ERR_INSPECTOR_ALREADY_CONNECTED, | |
| 6 | 5 | ERR_INSPECTOR_CLOSED, | |
@@ -9,13 +8,16 @@ const { | |||
| 9 | 8 | ERR_INVALID_ARG_TYPE, | |
| 10 | 9 | ERR_INVALID_CALLBACK | |
| 11 | 10 | } = require('internal/errors').codes; | |
| 11 | + | ||
| 12 | + const { hasInspector } = internalBinding('config'); | ||
| 13 | + if (!hasInspector) | ||
| 14 | + throw new ERR_INSPECTOR_NOT_AVAILABLE(); | ||
| 15 | + | ||
| 16 | + const EventEmitter = require('events'); | ||
| 12 | 17 | const { validateString } = require('internal/validators'); | |
| 13 | 18 | const util = require('util'); | |
| 14 | 19 | const { Connection, open, url } = internalBinding('inspector'); | |
| 15 | 20 | ||
| 16 | - if (!Connection) | ||
| 17 | - throw new ERR_INSPECTOR_NOT_AVAILABLE(); | ||
| 18 | - | ||
| 19 | 21 | const connectionSymbol = Symbol('connectionProperty'); | |
| 20 | 22 | const messageCallbacksSymbol = Symbol('messageCallbacks'); | |
| 21 | 23 | const nextIdSymbol = Symbol('nextId'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ const { NativeModule } = require('internal/bootstrap/loaders'); | |||
| 9 | 9 | const { | |
| 10 | 10 | source, getCodeCache, compileFunction | |
| 11 | 11 | } = internalBinding('native_module'); | |
| 12 | - const { hasTracing } = process.binding('config'); | ||
| 12 | + const { hasTracing, hasInspector } = process.binding('config'); | ||
| 13 | 13 | ||
| 14 | 14 | const depsModule = Object.keys(source).filter( | |
| 15 | 15 | (key) => NativeModule.isDepsModule(key) || key.startsWith('internal/deps') | |
@@ -33,7 +33,7 @@ const cannotUseCache = [ | |||
| 33 | 33 | ||
| 34 | 34 | // Skip modules that cannot be required when they are not | |
| 35 | 35 | // built into the binary. | |
| 36 | - if (process.config.variables.v8_enable_inspector !== 1) { | ||
| 36 | + if (!hasInspector) { | ||
| 37 | 37 | cannotUseCache.push( | |
| 38 | 38 | 'inspector', | |
| 39 | 39 | 'internal/util/inspector', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,7 @@ | |||
| 19 | 19 | const { internalBinding, NativeModule } = loaderExports; | |
| 20 | 20 | ||
| 21 | 21 | const { getOptionValue } = NativeModule.require('internal/options'); | |
| 22 | + const config = internalBinding('config'); | ||
| 22 | 23 | ||
| 23 | 24 | function startup() { | |
| 24 | 25 | setupTraceCategoryState(); | |
@@ -156,7 +157,7 @@ function startup() { | |||
| 156 | 157 | NativeModule.require('internal/process/coverage').setupExitHooks(); | |
| 157 | 158 | } | |
| 158 | 159 | ||
| 159 | - if (process.config.variables.v8_enable_inspector) { | ||
| 160 | + if (config.hasInspector) { | ||
| 160 | 161 | NativeModule.require('internal/inspector_async_hook').setup(); | |
| 161 | 162 | } | |
| 162 | 163 | ||
@@ -296,7 +297,7 @@ function startup() { | |||
| 296 | 297 | ||
| 297 | 298 | // TODO(joyeecheung): this property has not been well-maintained, should we | |
| 298 | 299 | // deprecate it in favor of a better API? | |
| 299 | - const { isDebugBuild, hasOpenSSL } = internalBinding('config'); | ||
| 300 | + const { isDebugBuild, hasOpenSSL } = config; | ||
| 300 | 301 | Object.defineProperty(process, 'features', { | |
| 301 | 302 | enumerable: true, | |
| 302 | 303 | writable: false, | |
@@ -636,7 +637,7 @@ function setupGlobalConsole() { | |||
| 636 | 637 | writable: true | |
| 637 | 638 | }); | |
| 638 | 639 | // TODO(joyeecheung): can we skip this if inspector is not active? | |
| 639 | - if (process.config.variables.v8_enable_inspector) { | ||
| 640 | + if (config.hasInspector) { | ||
| 640 | 641 | const inspector = | |
| 641 | 642 | NativeModule.require('internal/console/inspector'); | |
| 642 | 643 | inspector.addInspectorApis(consoleFromNode, consoleFromVM); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,12 +51,13 @@ function disableAllAsyncHooks() { | |||
| 51 | 51 | exports.writeCoverage = writeCoverage; | |
| 52 | 52 | ||
| 53 | 53 | function setup() { | |
| 54 | - const { Connection } = internalBinding('inspector'); | ||
| 55 | - if (!Connection) { | ||
| 54 | + const { hasInspector } = internalBinding('config'); | ||
| 55 | + if (!hasInspector) { | ||
| 56 | 56 | process._rawDebug('inspector not enabled'); | |
| 57 | 57 | return; | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | + const { Connection } = internalBinding('inspector'); | ||
| 60 | 61 | coverageConnection = new Connection((res) => { | |
| 61 | 62 | if (coverageConnection._coverageCallback) { | |
| 62 | 63 | coverageConnection._coverageCallback(res); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - const hasInspector = process.config.variables.v8_enable_inspector === 1; | ||
| 3 | + const { hasInspector } = internalBinding('config'); | ||
| 4 | 4 | const inspector = hasInspector ? require('inspector') : undefined; | |
| 5 | 5 | ||
| 6 | 6 | let session; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,6 +57,12 @@ static void Initialize(Local<Object> target, | |||
| 57 | 57 | READONLY_TRUE_PROPERTY(target, "hasTracing"); | |
| 58 | 58 | #endif | |
| 59 | 59 | ||
| 60 | + #if HAVE_INSPECTOR | ||
| 61 | + READONLY_TRUE_PROPERTY(target, "hasInspector"); | ||
| 62 | + #else | ||
| 63 | + READONLY_FALSE_PROPERTY(target, "hasInspector"); | ||
| 64 | + #endif | ||
| 65 | + | ||
| 60 | 66 | #if !defined(NODE_WITHOUT_NODE_OPTIONS) | |
| 61 | 67 | READONLY_TRUE_PROPERTY(target, "hasNodeOptions"); | |
| 62 | 68 | #endif | |
| Back | FazBrowse Home | New Git URL |
0 commit comments