@@ -94,8 +94,34 @@ export function extendOSEnvironPath(name, items, prepend = true) {
9494 } ) ;
9595}
9696
97+ /**
98+ * Run command helpers
99+ */
100+
97101const __RUN_CMD_QUEUE = [ ] ;
98102
103+ export function cleanCmdQueue ( ) {
104+ while ( __RUN_CMD_QUEUE . length ) {
105+ const callback = __RUN_CMD_QUEUE . pop ( ) [ 2 ] ;
106+ if ( callback ) {
107+ callback ( - 1 , undefined , new Error ( 'Terminated by user' ) ) ;
108+ }
109+ }
110+ }
111+
112+ function _removeComletedCmdfromQueue ( id ) {
113+ const index = __RUN_CMD_QUEUE . findIndex ( ( item ) => item [ 3 ] . _id === id ) ;
114+ if ( index > - 1 ) {
115+ __RUN_CMD_QUEUE . splice ( index , 1 ) ;
116+ }
117+ }
118+
119+ function _runNextCmdFromQueue ( ) {
120+ if ( __RUN_CMD_QUEUE . length > 0 ) {
121+ _runCommand ( ...__RUN_CMD_QUEUE . pop ( ) ) ;
122+ }
123+ }
124+
99125export function runCommand ( cmd , args , callback = undefined , options = { } ) {
100126 options = options || { } ;
101127 options . spawnOptions = options . spawnOptions || { } ;
@@ -171,18 +197,9 @@ function _runCommand(cmd, args, callback, options) {
171197 }
172198}
173199
174- function _removeComletedCmdfromQueue ( id ) {
175- const index = __RUN_CMD_QUEUE . findIndex ( ( item ) => item [ 3 ] . _id === id ) ;
176- if ( index > - 1 ) {
177- __RUN_CMD_QUEUE . splice ( index , 1 ) ;
178- }
179- }
180-
181- function _runNextCmdFromQueue ( ) {
182- if ( __RUN_CMD_QUEUE . length > 0 ) {
183- _runCommand ( ...__RUN_CMD_QUEUE . pop ( ) ) ;
184- }
185- }
200+ /**
201+ * End run command helpers
202+ */
186203
187204export function getCommandOutput ( cmd , args , options = { } ) {
188205 return new Promise ( ( resolve , reject ) => {
0 commit comments