Skip to content

Commit

Permalink
fix: Check that wsl path exists before using wslpath to convert it (#105
Browse files Browse the repository at this point in the history
)
  • Loading branch information
appzuka authored and birtles committed Aug 13, 2019
1 parent a398dae commit 1eb7e1b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Expand Up @@ -79,10 +79,12 @@ var getAllPrefixesWsl = function () {
// it starts with a drive and then record that.
var re = /^([A-Z]):\\/i
for (var pathElem of process.env.PATH.split(':')) {
var windowsPath = execSync('wslpath -w "' + pathElem + '"').toString()
var matches = windowsPath.match(re)
if (matches !== null && drives.indexOf(matches[1]) === -1) {
drives.push(matches[1])
if (fs.existsSync(pathElem)) {
var windowsPath = execSync('wslpath -w "' + pathElem + '"').toString()
var matches = windowsPath.match(re)
if (matches !== null && drives.indexOf(matches[1]) === -1) {
drives.push(matches[1])
}
}
}

Expand Down

0 comments on commit 1eb7e1b

Please sign in to comment.