nl_tokens: runs exec or exexfile modules . writePaths : { cmd : node args : [ test modules . writePaths ] switches : { dest : _ . path . join ( TEMP_PATH paths . json ) } }
pl_tokens: function cmd ( options , callback ) { let opts = _ . merge ( { } , DEFAULTS , options ) let { cmd = '' , type = '' , args = [ ] , switches = { } } = opts type = type && _ . isString ( type ) && _ . includes ( [ 'exec' , 'execFile' ] , type ) ? type : 'exec' args = args && _ . isArray ( args ) ? args : [ ] switches = switches && _ . isPlainObject ( switches ) ? _ . merge ( switches , _ . omit ( JARGV || { } , [ '_' ] ) ) || { } : { } let method = _ . get ( cproc , type ) if ( ! cmd || ! _ . isString ( cmd ) ) return _ . fail ( 'Invalid cmd' , <mask> ) if ( ! _ . isFunction ( method ) ) return _ . fail ( 'Invalid type' , callback ) _ . forIn ( switches , ( v , k ) => { if ( ! v && ! k ) return let arg = v && k ? ` ${ k } ${ v } ` : ` ${ k || v } ` if ( arg ) args . push ( arg ) } ) args = _ . compact ( args ) let isExec = type === 'exec' _ . assign ( opts , { args : args } ) opts = _ . omit ( opts , [ 'type' , 'switches' ] ) // exec does not take args argument like execFile // -> must join args with ' ' and append to cmd prop to create command if ( isExec ) cmd = _ . join ( [ cmd , _ . join ( args , ' ' ) ] , ' ' ) let cb = ( err , stdout , stderr ) => { if ( err ) return _ . fail ( err , callback ) _ . done ( { stdout : stdout , stderr : stderr } , callback ) } const child = isExec ? _ . attempt ( method , cmd , opts , cb ) : _ . attempt ( method , cmd , args , opts , cb ) return child //return _handleChild(child, _.cb(callback)) }