Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 1c31bf7

Browse files
author
Jan Krems
committed
chore: Support embedded mode
1 parent 2a96fa2 commit 1c31bf7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/_inspect.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,18 @@ const { spawn } = require('child_process');
2424
const { EventEmitter } = require('events');
2525
const util = require('util');
2626

27-
const InspectClient = require('./internal/inspect_client');
28-
const createRepl = require('./internal/inspect_repl');
27+
const [ InspectClient, createRepl ] =
28+
(typeof __dirname !== 'undefined') ?
29+
// This copy of node-inspect is on-disk, relative paths make sense.
30+
[
31+
require('./internal/inspect_client'),
32+
require('./internal/inspect_repl')
33+
] :
34+
// This copy of node-inspect is built into the node executable.
35+
[
36+
require('node-inspect/lib/internal/inspect_client'),
37+
require('node-inspect/lib/internal/inspect_repl')
38+
];
2939

3040
const debuglog = util.debuglog('inspect');
3141

test/cli/start-cli.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
'use strict';
22
const spawn = require('child_process').spawn;
33

4-
const CLI = require.resolve('../../cli.js');
4+
const CLI =
5+
process.env.USE_EMBEDDED_NODE_INSPECT === '1' ?
6+
'inspect' :
7+
require.resolve('../../cli.js');
58

69
function startCLI(args) {
710
const child = spawn(process.execPath, [CLI, ...args]);

0 commit comments

Comments
 (0)