-
Notifications
You must be signed in to change notification settings - Fork 3
/
debug.js
executable file
·66 lines (55 loc) · 1.25 KB
/
debug.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var semver = require('semver');
/**
* This function maps the current behaviour of the 'auto' flag
* in VSCode's launch/attach task definitions.
*
* Ref: https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_supported-nodelike-runtimes
*
* @returns {string} The debug flag to pass to fork when starting a worker
*/
exports.getDebugFlagName = function () {
var version = process.version;
if (semver.lt(version, '8.0.0')) {
return '--debug';
}
return '--inspect';
};
/**
*
*
* @returns
*/
exports.getDebugFlagHost = function () {
return process.env.DEBUG_HOST || '127.0.0.1';
};
/**
* Debug port to listen on
*/
exports.port = 5858;
/**
* @param {string} flag Debug flag currrently used
*/
exports.setDebugPortForFlag = function (flag) {
if (flag === '--debug') {
this.port = 5858;
} else {
this.port = 9229;
}
};
let workerPort = 2501; // GisT!
/**
* @returns {Number} Port value
*/
exports.getWorkerDebugPort = function () {
return workerPort;
};
exports.incrementDebugPort = function () {
return workerPort += 1;
};
exports.applyCPForkFlagsHack = function (execArgv, debugFlag) {
execArgv = execArgv.filter(function (flag) {
return !flag.match(/^(--inspect|--debug)/);
});
execArgv.unshift(debugFlag);
return execArgv;
};