@@ -4,6 +4,9 @@ import { resolve as nodeResolve } from 'path';
4
4
import { parse , build } from 'plist' ;
5
5
import { parseString , Builder } from 'xml2js' ;
6
6
import { readFileSync , writeFileSync } from 'fs-extra' ;
7
+ import { quoteString } from './helpers' ;
8
+
9
+ const isWindows = process . platform === 'win32' ;
7
10
8
11
export interface BuildExecutorSchema {
9
12
debug ?: boolean ;
@@ -126,7 +129,7 @@ export function commonExecutor(options: BuildExecutorSchema | TestExecutorSchema
126
129
}
127
130
}
128
131
129
- const nsOptions = [ ] ;
132
+ let nsOptions = [ ] ;
130
133
if ( isTesting ) {
131
134
nsOptions . push ( 'test' ) ;
132
135
}
@@ -228,7 +231,7 @@ export function commonExecutor(options: BuildExecutorSchema | TestExecutorSchema
228
231
} ;
229
232
// additional cli flags
230
233
// console.log('projectTargetCmdIndex:', projectTargetCmdIndex)
231
- const additionalArgs = [ ] ;
234
+ let additionalArgs = [ ] ;
232
235
if ( options . flags ) {
233
236
// persisted flags in configurations
234
237
additionalArgs . push ( ...options . flags . split ( ' ' ) ) ;
@@ -259,6 +262,11 @@ export function commonExecutor(options: BuildExecutorSchema | TestExecutorSchema
259
262
icon = '🥽' ;
260
263
}
261
264
}
265
+ if ( isWindows ) {
266
+ // https://github.com/NativeScript/nativescript-cli/pull/5808
267
+ nsOptions = nsOptions . map ( ( arg ) => quoteString ( arg ) ) ;
268
+ additionalArgs = additionalArgs . map ( ( arg ) => quoteString ( arg ) ) ;
269
+ }
262
270
console . log ( `―――――――――――――――――――――――― ${ icon } ` ) ;
263
271
console . log ( `Running NativeScript ${ isTesting ? 'unit tests' : 'CLI' } within ${ projectCwd } ` ) ;
264
272
console . log ( ' ' ) ;
@@ -272,6 +280,7 @@ export function commonExecutor(options: BuildExecutorSchema | TestExecutorSchema
272
280
const child = childProcess . spawn ( / ^ w i n / . test ( process . platform ) ? 'ns.cmd' : 'ns' , [ ...nsOptions , ...additionalArgs ] , {
273
281
cwd : projectCwd ,
274
282
stdio : 'inherit' ,
283
+ shell : isWindows ? true : undefined ,
275
284
} ) ;
276
285
child . on ( 'close' , ( code ) => {
277
286
console . log ( `Done.` ) ;
@@ -282,8 +291,13 @@ export function commonExecutor(options: BuildExecutorSchema | TestExecutorSchema
282
291
283
292
const checkAppId = function ( ) {
284
293
return new Promise ( ( resolve ) => {
285
- const child = childProcess . spawn ( / ^ w i n / . test ( process . platform ) ? 'ns.cmd' : 'ns' , [ 'config' , 'get' , `id` ] , {
294
+ let args = [ 'config' , 'get' , `id` ] ;
295
+ if ( isWindows ) {
296
+ args = args . map ( ( arg ) => quoteString ( arg ) ) ;
297
+ }
298
+ const child = childProcess . spawn ( / ^ w i n / . test ( process . platform ) ? 'ns.cmd' : 'ns' , args , {
286
299
cwd : projectCwd ,
300
+ shell : isWindows ? true : undefined ,
287
301
} ) ;
288
302
child . stdout . setEncoding ( 'utf8' ) ;
289
303
child . stdout . on ( 'data' , function ( data ) {
@@ -304,9 +318,14 @@ export function commonExecutor(options: BuildExecutorSchema | TestExecutorSchema
304
318
checkAppId ( ) . then ( ( id ) => {
305
319
if ( options . id !== id ) {
306
320
// set custom app bundle id before running the app
307
- const child = childProcess . spawn ( / ^ w i n / . test ( process . platform ) ? 'ns.cmd' : 'ns' , [ 'config' , 'set' , `${ options . platform } .id` , options . id ] , {
321
+ let args = [ 'config' , 'set' , `${ options . platform } .id` , options . id ] ;
322
+ if ( isWindows ) {
323
+ args = args . map ( ( arg ) => quoteString ( arg ) ) ;
324
+ }
325
+ const child = childProcess . spawn ( / ^ w i n / . test ( process . platform ) ? 'ns.cmd' : 'ns' , args , {
308
326
cwd : projectCwd ,
309
327
stdio : 'inherit' ,
328
+ shell : isWindows ? true : undefined ,
310
329
} ) ;
311
330
child . on ( 'close' , ( code ) => {
312
331
child . kill ( 'SIGKILL' ) ;
0 commit comments