Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: program location in wsl (#309) #636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/lib/util/opener.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const child_process_1 = tslib_1.__importDefault(require("child_process"));
const os_1 = tslib_1.__importDefault(require("os"));
module.exports = function opener(args, tool) {
let platform = process.platform;
let is_wsl = false;
args = [].concat(args);
// Attempt to detect Windows Subystem for Linux (WSL).
// WSL itself as Linux (which works in most cases), but in
Expand All @@ -16,12 +17,18 @@ module.exports = function opener(args, tool) {
// whereas using xdg-open does not, since there is no X Windows in WSL.
if (platform === 'linux' && os_1.default.release().toLowerCase().indexOf('microsoft') !== -1) {
platform = 'win32';
is_wsl = true;
}
// http://stackoverflow.com/q/1480971/3191, but see below for Windows.
let command;
switch (platform) {
case 'win32': {
command = 'cmd.exe';
if (is_wsl) {
command = '/mnt/c/Windows/System32/cmd.exe';
}
else {
command = 'cmd.exe';
}
if (tool) {
args.unshift(tool);
}
Expand Down
8 changes: 7 additions & 1 deletion src/util/opener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = function opener(
tool: string | undefined
) {
let platform = process.platform
let is_wsl = false
args = [].concat(args)

// Attempt to detect Windows Subystem for Linux (WSL).
Expand All @@ -18,13 +19,18 @@ module.exports = function opener(
// whereas using xdg-open does not, since there is no X Windows in WSL.
if (platform === 'linux' && os.release().toLowerCase().indexOf('microsoft') !== -1) {
platform = 'win32'
is_wsl = true
}

// http://stackoverflow.com/q/1480971/3191, but see below for Windows.
let command
switch (platform) {
case 'win32': {
command = 'cmd.exe'
if (is_wsl) {
command = '/mnt/c/Windows/System32/cmd.exe'
} else {
command = 'cmd.exe'
}
if (tool) {
args.unshift(tool)
}
Expand Down