File tree Expand file tree Collapse file tree 1 file changed +12
-20
lines changed
Expand file tree Collapse file tree 1 file changed +12
-20
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
3- const fs = require ( 'fs' )
43const path = require ( 'path' )
54const spawn = require ( 'child_process' ) . spawn
65
@@ -10,28 +9,21 @@ var command = process.argv[1]
109var argv = process . argv . slice ( 2 )
1110
1211var index = PATH . indexOf ( path . dirname ( command ) )
13- if ( index >= 0 ) PATH = PATH . slice ( index + 1 )
12+ if ( index >= 0 )
13+ {
14+ PATH = PATH . slice ( index + 1 )
15+ process . env . PATH = PATH
16+ }
1417
15- command = path . basename ( command )
1618
17- function onExit ( code , signal )
19+ spawn ( path . basename ( command ) , argv , { stdio : 'inherit' } )
20+ . on ( 'exit' , function ( code , signal )
1821{
1922 process . exit ( code || signal )
20- }
21-
22- for ( var index in PATH )
23+ } )
24+ . on ( 'error' , function ( error )
2325{
24- var fullCommand = path . join ( PATH [ index ] , command )
25-
26- try
27- {
28- fs . accessSync ( fullCommand , fs . X_OK )
29-
30- return spawn ( fullCommand , argv , { stdio : 'inherit' } ) . on ( 'exit' , onExit )
31- }
32- catch ( e )
33- { }
34- }
35-
26+ if ( error . code === 'ENOENT' ) return process . exit ( 127 )
3627
37- process . exit ( 127 )
28+ throw error
29+ } )
You can’t perform that action at this time.
0 commit comments