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
Add support for Windows apps referenced by their WSL paths #118
Changes from 2 commits
bd06170
0390043
0fd474d
eeec5a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,8 +1,17 @@ | ||||||
'use strict'; | ||||||
const path = require('path'); | ||||||
const childProcess = require('child_process'); | ||||||
const util = require('util'); | ||||||
const isWsl = require('is-wsl'); | ||||||
|
||||||
// Converts a path from WSL format to Windows format | ||||||
// e.g. /mnt/c/Program Files/Example/MyApp.exe | ||||||
// => C:\Program Files\Example\MyApp.exe | ||||||
const wslToWindowsPath = async path => { | ||||||
const {stdout} = await util.promisify(childProcess.execFile)('wslpath', ['-w', path]); | ||||||
return stdout.toString().trim(); | ||||||
stephen-zhao marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
}; | ||||||
|
||||||
module.exports = async (target, options) => { | ||||||
if (typeof target !== 'string') { | ||||||
throw new TypeError('Expected a `target`'); | ||||||
|
@@ -43,6 +52,11 @@ module.exports = async (target, options) => { | |||||
} | ||||||
|
||||||
if (options.app) { | ||||||
if (isWsl && options.app.startsWith('/mnt/')) { | ||||||
const winPath = await wslToWindowsPath(options.app); | ||||||
options.app = winPath; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That fails atomic-assignment check since it reads |
||||||
} | ||||||
|
||||||
cliArguments.push(options.app); | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a long flag version of
-w
? For readability.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to promisify at the top-level instead of every time it's called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately
wslpath
doesn't have any long-form flags.