@@ -14,18 +14,13 @@ var node_modules = 'node_modules';
14
14
15
15
function writeOutput ( text , bufferedOutput , source , title ) {
16
16
17
- // split output by line
18
17
var lines = ( title + bufferedOutput + text ) . split ( / \r ? \n / ) ;
19
-
20
- // buffer content from last line, in case it hasn't been read completely
21
18
bufferedOutput = lines . pop ( ) ;
22
19
23
- // write complete lines to output
24
20
lines . forEach ( function ( line ) {
25
21
log . debug ( line , source ) ;
26
22
} ) ;
27
23
28
- // return buffered output
29
24
return bufferedOutput ;
30
25
}
31
26
@@ -47,21 +42,15 @@ function exec (command, args, options, callback) {
47
42
}
48
43
}
49
44
50
- // log command line
51
45
var title = 'Launching external process: \'' + command + ' ' + args . join ( ' ' ) + '\'\n' ;
52
-
53
- // spawn new process
54
46
var childProcess = child_process . spawn ( command , args , options ) ;
55
47
56
- // show progress indicator
57
48
if ( ! options . suppressOutput ) {
58
49
progress . start ( options . statusMessage ) ;
59
50
}
60
51
61
- // console log source displays the process ID
62
52
var source = 'pid:' + childProcess . pid ;
63
53
64
- // capture stdout
65
54
childProcess . stdout . on ( 'data' , function ( data ) {
66
55
var text = data . toString ( ) ;
67
56
stdout += text ;
@@ -74,7 +63,6 @@ function exec (command, args, options, callback) {
74
63
}
75
64
} ) ;
76
65
77
- // capture stderr
78
66
childProcess . stderr . on ( 'data' , function ( data ) {
79
67
var text = data . toString ( ) ;
80
68
stderr += text ;
@@ -87,14 +75,11 @@ function exec (command, args, options, callback) {
87
75
}
88
76
} ) ;
89
77
90
- // handle errors
91
78
childProcess . on ( 'error' , function ( err ) {
92
79
return deferred . reject ( err ) ;
93
80
} ) ;
94
81
95
- // process has exited
96
82
childProcess . on ( 'exit' , function ( code ) {
97
- // write pending output to console
98
83
if ( bufferedStdout ) {
99
84
writeOutput ( bufferedStdout ) ;
100
85
}
@@ -137,7 +122,7 @@ function getCommandPath(currentPath, command) {
137
122
return Q . reject ( err ) ;
138
123
}
139
124
140
- currentPath = currentPath . substring ( 0 , currentPath . lastIndexOf ( path . sep ) ) ;
125
+ currentPath = currentPath . substring ( 0 , currentPath . lastIndexOf ( path . sep ) ) ;
141
126
if ( currentPath . indexOf ( node_modules ) >= 0 ) {
142
127
if ( currentPath . substr ( currentPath . length - node_modules . length ) === node_modules ) {
143
128
currentPath = currentPath . substring ( 0 , currentPath . length - node_modules . length ) ;
0 commit comments