Skip to content

Commit 315a480

Browse files
authoredJan 30, 2021
Remove usage of wslu (#217)
1 parent 3182c38 commit 315a480

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed
 

‎index.js

+5-30
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,10 @@ const isWsl = require('is-wsl');
77
const isDocker = require('is-docker');
88

99
const pAccess = promisify(fs.access);
10-
const pExecFile = promisify(childProcess.execFile);
1110

1211
// Path to included `xdg-open`.
1312
const localXdgOpenPath = path.join(__dirname, 'xdg-open');
1413

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-
3414
module.exports = async (target, options) => {
3515
if (typeof target !== 'string') {
3616
throw new TypeError('Expected a `target`');
@@ -69,8 +49,10 @@ module.exports = async (target, options) => {
6949
cliArguments.push('-a', app);
7050
}
7151
} 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+
7456
cliArguments.push(
7557
'-NoProfile',
7658
'-NonInteractive',
@@ -79,9 +61,7 @@ module.exports = async (target, options) => {
7961
'-EncodedCommand'
8062
);
8163

82-
if (isWsl) {
83-
command = await windowsToWslPath(command);
84-
} else {
64+
if (!isWsl) {
8565
childProcessOptions.windowsVerbatimArguments = true;
8666
}
8767

@@ -92,11 +72,6 @@ module.exports = async (target, options) => {
9272
}
9373

9474
if (app) {
95-
if (isWsl && app.startsWith('/')) {
96-
const windowsPath = await wslToWindowsPath(app);
97-
app = windowsPath;
98-
}
99-
10075
// Double quote with double quotes to ensure the inner quotes are passed through.
10176
// Inner quotes are delimited for PowerShell interpretation with backticks.
10277
encodedArguments.push(`"\`"${app}\`""`, '-ArgumentList');

0 commit comments

Comments
 (0)
Please sign in to comment.