From 1eb7e1b145d4e264602eb0b14f7e4777686fb4a7 Mon Sep 17 00:00:00 2001 From: appzuka Date: Tue, 13 Aug 2019 13:26:01 +0100 Subject: [PATCH] fix: Check that wsl path exists before using wslpath to convert it (#105) --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index df0dd83..2586386 100755 --- a/index.js +++ b/index.js @@ -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]) + } } }