File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,18 @@ const wslToWindowsPath = async path => {
19
19
return stdout . trim ( ) ;
20
20
} ;
21
21
22
+ // Convert a path from Windows format to WSL format
23
+ const windowsToWslPath = async path => {
24
+ const { stdout} = await pExecFile ( 'wslpath' , [ path ] ) ;
25
+ return stdout . trim ( ) ;
26
+ } ;
27
+
28
+ // Get an environment variable from Windows
29
+ const wslGetWindowsEnvVar = async envVar => {
30
+ const { stdout} = await pExecFile ( 'wslvar' , [ envVar ] ) ;
31
+ return stdout . trim ( ) ;
32
+ } ;
33
+
22
34
module . exports = async ( target , options ) => {
23
35
if ( typeof target !== 'string' ) {
24
36
throw new TypeError ( 'Expected a `target`' ) ;
@@ -57,7 +69,8 @@ module.exports = async (target, options) => {
57
69
cliArguments . push ( '-a' , app ) ;
58
70
}
59
71
} else if ( process . platform === 'win32' || ( isWsl && ! isDocker ( ) ) ) {
60
- command = 'powershell' + ( isWsl ? '.exe' : '' ) ;
72
+ const windowsRoot = isWsl ? await wslGetWindowsEnvVar ( 'systemroot' ) : process . env . SYSTEMROOT ;
73
+ command = String . raw `${ windowsRoot } \System32\WindowsPowerShell\v1.0\powershell${ isWsl ? '.exe' : '' } ` ;
61
74
cliArguments . push (
62
75
'-NoProfile' ,
63
76
'-NonInteractive' ,
@@ -66,7 +79,9 @@ module.exports = async (target, options) => {
66
79
'-EncodedCommand'
67
80
) ;
68
81
69
- if ( ! isWsl ) {
82
+ if ( isWsl ) {
83
+ command = await windowsToWslPath ( command ) ;
84
+ } else {
70
85
childProcessOptions . windowsVerbatimArguments = true ;
71
86
}
72
87
You can’t perform that action at this time.
0 commit comments