@@ -2,6 +2,7 @@ import {spawn, execSync, ChildProcess} from 'child_process';
2
2
import { Version } from '../common/version' ;
3
3
import { Logger , Tags } from '../common/logger' ;
4
4
import * as utils from '../common/utilities' ;
5
+ import * as os from 'os' ;
5
6
6
7
export enum CliVersionState {
7
8
NotExisting ,
@@ -44,13 +45,22 @@ export class CliVersion {
44
45
45
46
export class NativeScriptCli {
46
47
private _path : string ;
48
+ private _shellPath : string ;
47
49
private _cliVersion : CliVersion ;
48
50
private _logger : Logger ;
49
51
50
52
constructor ( cliPath : string , logger : Logger ) {
51
53
this . _path = cliPath ;
52
54
this . _logger = logger ;
53
55
56
+ this . _shellPath = process . env . SHELL ;
57
+
58
+ // always default to cmd on Windows
59
+ // workaround for issue #121 https://github.com/NativeScript/nativescript-vscode-extension/issues/121
60
+ if ( os . platform ( ) . indexOf ( "win" ) != - 1 ) {
61
+ this . _shellPath = "cmd.exe" ;
62
+ }
63
+
54
64
let versionStr = null ;
55
65
try {
56
66
versionStr = this . executeSync ( [ "--version" ] , undefined ) ;
@@ -73,16 +83,17 @@ export class NativeScriptCli {
73
83
}
74
84
75
85
public executeSync ( args : string [ ] , cwd : string ) : string {
76
- let command : string = `${ this . _path } ` + args . join ( ' ' ) ;
86
+ let command : string = `${ this . _path } ${ args . join ( ' ' ) } ` ;
77
87
this . _logger . log ( `[NativeScriptCli] execute: ${ command } ` , Tags . FrontendMessage ) ;
78
- return execSync ( command , { encoding : "utf8" , cwd : cwd , shell : process . env . SHELL } ) . toString ( ) . trim ( ) ;
88
+
89
+ return execSync ( command , { encoding : "utf8" , cwd : cwd , shell : this . _shellPath } ) . toString ( ) . trim ( ) ;
79
90
}
80
91
81
92
public execute ( args : string [ ] , cwd : string ) : ChildProcess {
82
- let command : string = `${ this . _path } ` + args . join ( ' ' ) ;
93
+ let command : string = `${ this . _path } ${ args . join ( ' ' ) } ` ;
83
94
this . _logger . log ( `[NativeScriptCli] execute: ${ command } ` , Tags . FrontendMessage ) ;
84
95
85
- let options = { cwd : cwd , shell : process . env . SHELL } ;
96
+ let options = { cwd : cwd , shell : this . _shellPath } ;
86
97
let child : ChildProcess = spawn ( this . _path , args , options ) ;
87
98
child . stdout . setEncoding ( 'utf8' ) ;
88
99
child . stderr . setEncoding ( 'utf8' ) ;
0 commit comments