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

Commit 46bd31d

Browse files
committed
[SQUASH] compat with <7.6.0
1 parent d4680e1 commit 46bd31d

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

lib/_inspect.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
const { spawn } = require('child_process');
2424
const { EventEmitter } = require('events');
2525
const net = require('net');
26+
const semver = require('semver');
2627
const util = require('util');
2728

2829
const runAsStandalone = typeof __dirname !== 'undefined';
@@ -94,30 +95,30 @@ function portIsFree(host, port, timeout = 2000) {
9495

9596
function runScript(script, scriptArgs, inspectHost, inspectPort, childPrint) {
9697
return portIsFree(inspectHost, inspectPort)
97-
.then(() => {
98-
return new Promise((resolve) => {
99-
const args = [
100-
'--inspect',
101-
`--inspect-brk=${inspectPort}`,
102-
].concat([script], scriptArgs);
103-
const child = spawn(process.execPath, args);
104-
child.stdout.setEncoding('utf8');
105-
child.stderr.setEncoding('utf8');
106-
child.stdout.on('data', childPrint);
107-
child.stderr.on('data', childPrint);
108-
109-
let output = '';
110-
function waitForListenHint(text) {
111-
output += text;
112-
if (/chrome-devtools:\/\//.test(output)) {
113-
child.stderr.removeListener('data', waitForListenHint);
114-
resolve(child);
98+
.then(() => {
99+
return new Promise((resolve) => {
100+
const args = (semver.satisfies(process.version, '>=7.6.0') ?
101+
[`--inspect-brk=${inspectPort}`] :
102+
['--inspect', `--debug-brk=${inspectPort}`])
103+
.concat([script], scriptArgs);
104+
const child = spawn(process.execPath, args);
105+
child.stdout.setEncoding('utf8');
106+
child.stderr.setEncoding('utf8');
107+
child.stdout.on('data', childPrint);
108+
child.stderr.on('data', childPrint);
109+
110+
let output = '';
111+
function waitForListenHint(text) {
112+
output += text;
113+
if (/chrome-devtools:\/\//.test(output)) {
114+
child.stderr.removeListener('data', waitForListenHint);
115+
resolve(child);
116+
}
115117
}
116-
}
117118

118-
child.stderr.on('data', waitForListenHint);
119+
child.stderr.on('data', waitForListenHint);
120+
});
119121
});
120-
});
121122
}
122123

123124
function createAgentProxy(domain, client) {

0 commit comments

Comments
 (0)