From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/worker-farm/lib/fork.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 node_modules/worker-farm/lib/fork.js (limited to 'node_modules/worker-farm/lib/fork.js') diff --git a/node_modules/worker-farm/lib/fork.js b/node_modules/worker-farm/lib/fork.js new file mode 100644 index 00000000..2843df48 --- /dev/null +++ b/node_modules/worker-farm/lib/fork.js @@ -0,0 +1,33 @@ +'use strict' + +const childProcess = require('child_process') + , childModule = require.resolve('./child/index') + + +function fork (forkModule, workerOptions) { + // suppress --debug / --inspect flags while preserving others (like --harmony) + let filteredArgs = process.execArgv.filter(function (v) { + return !(/^--(debug|inspect)/).test(v) + }) + , options = Object.assign({ + execArgv : filteredArgs + , env : process.env + , cwd : process.cwd() + }, workerOptions) + , child = childProcess.fork(childModule, process.argv, options) + + child.on('error', function() { + // this *should* be picked up by onExit and the operation requeued + }) + + child.send({ module: forkModule }) + + // return a send() function for this child + return { + send : child.send.bind(child) + , child : child + } +} + + +module.exports = fork -- cgit v1.2.3