@@ -7,30 +7,10 @@ const isWsl = require('is-wsl');
7
7
const isDocker = require ( 'is-docker' ) ;
8
8
9
9
const pAccess = promisify ( fs . access ) ;
10
- const pExecFile = promisify ( childProcess . execFile ) ;
11
10
12
11
// Path to included `xdg-open`.
13
12
const localXdgOpenPath = path . join ( __dirname , 'xdg-open' ) ;
14
13
15
- // Convert a path from WSL format to Windows format:
16
- // `/mnt/c/Program Files/Example/MyApp.exe` → `C:\Program Files\Example\MyApp.exe`
17
- const wslToWindowsPath = async path => {
18
- const { stdout} = await pExecFile ( 'wslpath' , [ '-w' , path ] ) ;
19
- return stdout . trim ( ) ;
20
- } ;
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
-
34
14
module . exports = async ( target , options ) => {
35
15
if ( typeof target !== 'string' ) {
36
16
throw new TypeError ( 'Expected a `target`' ) ;
@@ -69,8 +49,10 @@ module.exports = async (target, options) => {
69
49
cliArguments . push ( '-a' , app ) ;
70
50
}
71
51
} else if ( process . platform === 'win32' || ( isWsl && ! isDocker ( ) ) ) {
72
- const windowsRoot = isWsl ? await wslGetWindowsEnvVar ( 'systemroot' ) : process . env . SYSTEMROOT ;
73
- command = String . raw `${ windowsRoot } \System32\WindowsPowerShell\v1.0\powershell${ isWsl ? '.exe' : '' } ` ;
52
+ command = isWsl ?
53
+ '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe' :
54
+ `${ process . env . SYSTEMROOT } \\System32\\WindowsPowerShell\\v1.0\\powershell` ;
55
+
74
56
cliArguments . push (
75
57
'-NoProfile' ,
76
58
'-NonInteractive' ,
@@ -79,9 +61,7 @@ module.exports = async (target, options) => {
79
61
'-EncodedCommand'
80
62
) ;
81
63
82
- if ( isWsl ) {
83
- command = await windowsToWslPath ( command ) ;
84
- } else {
64
+ if ( ! isWsl ) {
85
65
childProcessOptions . windowsVerbatimArguments = true ;
86
66
}
87
67
@@ -92,11 +72,6 @@ module.exports = async (target, options) => {
92
72
}
93
73
94
74
if ( app ) {
95
- if ( isWsl && app . startsWith ( '/' ) ) {
96
- const windowsPath = await wslToWindowsPath ( app ) ;
97
- app = windowsPath ;
98
- }
99
-
100
75
// Double quote with double quotes to ensure the inner quotes are passed through.
101
76
// Inner quotes are delimited for PowerShell interpretation with backticks.
102
77
encodedArguments . push ( `"\`"${ app } \`""` , '-ArgumentList' ) ;
0 commit comments