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

Add support for Windows apps referenced by their WSL paths #118

Merged
merged 4 commits into from Mar 26, 2019

Conversation

stephen-zhao
Copy link
Contributor

@stephen-zhao stephen-zhao commented Mar 18, 2019

Fixes #117

@stephen-zhao
Copy link
Contributor Author

Sorry, let me fix these xo errors.

index.js Outdated
// 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]);
Copy link
Owner

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.

Copy link
Owner

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.

const pExecFile = util.promisify(childProcess.execFile);

Copy link
Contributor Author

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.

index.js Outdated Show resolved Hide resolved
@@ -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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options.app = winPath;
options.app = await wslToWindowsPath(options.app);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That fails atomic-assignment check since it reads options.app first and asynchronously reassigns to it, during which, theoretically, someone else can come to modify options.app and its modification will be lost. (This was discovered by xo).

@sindresorhus
Copy link
Owner

Can you mention in the readme that it now correctly handles WSL mtn paths?

@stephen-zhao
Copy link
Contributor Author

@sindresorhus I think it's ready to be merged now?

@sindresorhus sindresorhus changed the title Add support for windows apps referenced by their WSL paths Add support for Windows apps referenced by their WSL paths Mar 26, 2019
@sindresorhus sindresorhus merged commit b30220c into sindresorhus:master Mar 26, 2019
@sindresorhus
Copy link
Owner

Yup. Looks good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants