-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.js
52 lines (47 loc) · 1.2 KB
/
index.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
'use strict';
const is = require('is-type-of');
const Coffee = require('./lib/coffee');
const Rule = require('./lib/rule');
exports.Coffee = Coffee;
exports.Rule = Rule;
/**
* fork a child process to test
* @param {String} modulePath - The module to run in the child
* @param {Array} args - List of string arguments
* @param {Object} opt - fork options
* @see https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
* @return {Coffee} coffee instance
*/
exports.fork = function(modulePath, args, opt) {
// fork('/path/to/cli', { execArgv: [] })
if (!opt && !is.array(args)) {
opt = args;
args = undefined;
}
return new Coffee({
method: 'fork',
cmd: modulePath,
args,
opt,
});
};
/**
* spawn a child process to test
* @param {String} cmd - The command to run
* @param {Array} args - List of string arguments
* @param {Object} opt - spawn options
* @return {Coffee} coffee instance
*/
exports.spawn = function(cmd, args, opt) {
// spawn('/path/to/cli', { execArgv: [] })
if (!opt && !is.array(args)) {
opt = args;
args = undefined;
}
return new Coffee({
method: 'spawn',
cmd,
args,
opt,
});
};