@@ -59,7 +59,7 @@ Spawnify.prototype._onMessage = function onMessage(command, options) {
5959 '~' , '>' , '<' , '#' ,
6060 '*' , '&' , '{' , '}' ,
6161 '|' , '\'' , '"' , ';' ,
62- '`' , '$'
62+ '`' , '$' ,
6363 ] ;
6464
6565 const isSymbol = isContain ( command , symbolsExec ) ;
@@ -76,7 +76,7 @@ Spawnify.prototype._onMessage = function onMessage(command, options) {
7676 if ( WIN )
7777 command = 'cmd /C ' + command ;
7878
79- const firstChar = command [ 0 ] ;
79+ const [ firstChar ] = command ;
8080
8181 if ( firstChar === ' ' || isSymbol )
8282 this . _set ( 'exec' , command , options ) ;
@@ -97,7 +97,7 @@ Spawnify.prototype._emit = function emit(event, data) {
9797 if ( count ( event ) || event === 'error' ) {
9898 this . emit ( event , data ) ;
9999
100- /*
100+ /*
101101 * when code is EACESS
102102 * close and exit events
103103 * whould not be emitted
@@ -113,7 +113,9 @@ Spawnify.prototype._emit = function emit(event, data) {
113113} ;
114114
115115Spawnify . prototype . _set = function set ( type , command , options ) {
116- let args , error , child ;
116+ let args ;
117+ let error ;
118+ let child ;
117119 let result ;
118120
119121 assert ( type , 'event could not be empty!' ) ;
@@ -129,7 +131,7 @@ Spawnify.prototype._set = function set(type, command, options) {
129131 case 'exec' :
130132 result = tryCatch ( exec , command , options ) ;
131133
132- error = result [ 0 ] ;
134+ [ error ] = result ;
133135 child = result [ 1 ] ;
134136 break ;
135137
@@ -139,7 +141,7 @@ Spawnify.prototype._set = function set(type, command, options) {
139141
140142 result = tryCatch ( spawn , command , args , options ) ;
141143
142- error = result [ 0 ] ;
144+ [ error ] = result ;
143145 child = result [ 1 ] ;
144146 break ;
145147 }
@@ -189,20 +191,20 @@ Spawnify.prototype._setListeners = function setListeners(child) {
189191 child . stdin . on ( 'error' , ( error ) => {
190192 this . _emit ( 'error' , newLine ( error ) ) ;
191193 } ) ;
192-
194+
193195 if ( child . stdout ) {
194196 child . stdout
195197 . pipe ( win . unicodify ( ) )
196198 . setEncoding ( 'utf8' )
197199 . on ( 'data' , ( data ) => {
198200 this . _emit ( 'data' , data ) ;
199201 } ) ;
200-
202+
201203 child . stdout . on ( 'error' , ( error ) => {
202204 this . _emit ( 'error' , newLine ( error ) ) ;
203205 } ) ;
204206 }
205-
207+
206208 if ( child . stderr ) {
207209 child . stderr . pipe ( win . unicodify ( ) )
208210 . setEncoding ( 'utf8' )
@@ -263,15 +265,15 @@ Spawnify.prototype._onCD = function onCD(command, currDir) {
263265 CD ,
264266 paramDir ,
265267 '\'' + paramDir + '\'' ,
266- '"' + paramDir + '"' ,
268+ '"' + paramDir + '"' ,
267269 ] ;
268270
269- strs . forEach ( ( str ) => {
271+ for ( const str of strs ) {
270272 command = command . replace ( str , '' ) ;
271- } ) ;
273+ }
272274
273275 if ( ! isRoot )
274- paramDir = path . join ( currDir , paramDir ) ;
276+ paramDir = path . join ( currDir , paramDir ) ;
275277
276278 if ( isWildCard )
277279 command = CD + paramDir + ' ' + command ;
@@ -286,10 +288,10 @@ Spawnify.prototype._onCD = function onCD(command, currDir) {
286288 let cwd ;
287289
288290 if ( ! error )
289- cwd = dirs [ 0 ] ;
291+ [ cwd ] = dirs ;
290292
291293 this . _set ( 'exec' , command , {
292- cwd
294+ cwd,
293295 } ) ;
294296 } ) ;
295297} ;
@@ -305,7 +307,7 @@ Spawnify.prototype._getFirstWord = function getFirstWord(str) {
305307 if ( ! is )
306308 return str ;
307309
308- let result = str . match ( regExpQuotes ) ;
310+ let result = str . match ( regExpQuotes ) ;
309311
310312 if ( result )
311313 return result [ 1 ] || str ;
0 commit comments