@@ -2,19 +2,26 @@ var fork = require('child_process').fork
22var path = require ( 'path' )
33var filewatcher = require ( 'filewatcher' )
44var ipc = require ( './ipc' )
5- var cli = require ( './cli ' )
5+ var resolveMain = require ( './resolveMain ' )
66
7- module . exports = function ( args ) {
87
9- // The child_process
10- var child
8+ module . exports = function ( wrapper , script , scriptArgs , opts ) {
9+ if ( typeof wrapper !== 'string' || wrapper . length === 0 ) {
10+ throw new TypeError ( '`wrapper` must be a string' )
11+ }
12+
13+ if ( typeof script !== 'string' || script . length === 0 ) {
14+ throw new TypeError ( '`script` must be a string' )
15+ }
1116
12- // Parse command line options
13- var opts = cli . parseOpts ( args )
17+ if ( ! Array . isArray ( scriptArgs ) ) {
18+ throw new TypeError ( '`scriptArgs` must be an array' )
19+ }
1420
15- // Inject wrap.js into the args array
16- var main = cli . injectScript ( args , __dirname + '/wrap.js' )
21+ // The child_process
22+ var child
1723
24+ var main = resolveMain ( script )
1825 var cfg = require ( './cfg' ) ( main , opts )
1926 var log = require ( './log' ) ( cfg )
2027 var notify = require ( './notify' ) ( cfg , log )
@@ -50,7 +57,8 @@ module.exports = function(args) {
5057 * Run the wrapped script.
5158 */
5259 function start ( ) {
53- child = fork ( args [ 0 ] , args . slice ( 1 ) , {
60+ var wrapperArgs = [ script ] . concat ( scriptArgs )
61+ child = fork ( wrapper , wrapperArgs , {
5462 cwd : process . cwd ( ) ,
5563 env : process . env
5664 } )
0 commit comments