Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fork = require("child_process").fork;
- let debugArg = process.execArgv.find(args => /^--(debug|inspect)/.test(args));
- const debugging = !!debugArg;
- debugArg = debugArg ? debugArg.replace('-brk', '').split('=') : ['--debug', 5859];
- let lastAddress = parseInt(debugArg[1], 10);
- function debugFork(modulePath, args, options) {
- let execArgv = [];
- if (global.v8debug || debugging) {
- lastAddress += 1;
- execArgv = [debugArg[0] + '=' + lastAddress, '--nolazy'];
- }
- if (!Array.isArray(args)) {
- options = args;
- args = [];
- }
- options = options || {};
- options = Object.assign({}, options, {execArgv});
- return fork(modulePath, args, options);
- }
- debugFork.debugging = debugging;
- module.exports = debugFork;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement