node-modules/childprocess

Name: childprocess

Owner: node_modules

Description: Wrap `child_process` module to support Multiple Process Code Coverage with istanbul.

Created: 2015-08-30 02:57:23.0

Updated: 2018-03-11 14:59:33.0

Pushed: 2016-07-18 13:57:02.0

Homepage: null

Size: 23

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

childprocess

NPM version build status appveyor build status Test coverage David deps npm download

Inject script into multiple process when using child_process.fork.

One of the use case is Multiple Process Code Coverage with istanbul.

Install
m i childprocess
Usage
ire('childprocess').inject(function(modulePath, args, opt) {
nst execFile = 'path/to/istanbul';
nst cwd = opt.cwd && process.cwd();
nst execArgs = [
'cover',
'--root', cwd,
'--dir', path.join(cwd, './coverage'),
'--report', 'none',
'--print', 'none',
'--include-pid',
modulePath,
'--',
concat(args);
turn [execFile, execArgs, opt];

ire('child_process').fork();
APIs
inject(cb) / inject(filepath)

Inject script when using child_process.fork.

The inject script is a function that running in sandbox in every process. that mean you can't use the variable out of the function.

The function should return an array that contains 3 arguments same as fork.

dprocess.inject(function(modulePath, args, opt) {
turn [modulePath, args, opt];

reset()

Use child_process.fork without injected script.

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.