Convert to windows paths when using WSL
`open(process.cwd())` currently does nothing when using WSL. I would expect it to open explorer.exe to the current folder.
It seems like this is because the path is not recognized, but this can be fixed using the `wslpath` utility available on WSL systems: `wslpath -aw "$path"`.
The easy solution is to always let WSL go through to `xdg-open`, i.e. remove the second part of the condition for win32 [here](https://github.com/sindresorhus/open/blob/39f7d2d4812f56ef77b2affec8e2110c89c27224/index.js#L161), since the current `xdg-open` takes care of this automatically [here](https://github.com/sindresorhus/open/blob/39f7d2d4812f56ef77b2affec8e2110c89c27224/xdg-open#L1059)
Alternatively, we could try calling `wslpath` (or re-implementing its logic) before encoding the target for the PowerShell arguments. Something along the lines of (except maybe with some error handling):
```js
let target = options.target;
if (isWsl) {
const {stdout} = await execFile('wslpath', ['-wa', target], {encoding: 'utf8'});
target = stdout.trim();
}
```
Is there a preferred solution? Or anything I am missing? Happy to create a PR if that helps.
0 条评论