Skip to content

Commit f4df68a

Browse files
authoredFeb 16, 2021
WSL: Fix mount point issue (#224)
1 parent f0533c0 commit f4df68a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed
 

‎index.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Get the mount point for fixed drives in WSL.
1919
@returns {string} The mount point.
2020
*/
2121
const getWslDrivesMountPoint = (() => {
22+
// Default value for "root" param
23+
// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config
24+
const defaultMountPoint = '/mnt/';
25+
2226
let mountPoint;
2327

2428
return async function () {
@@ -36,14 +40,17 @@ const getWslDrivesMountPoint = (() => {
3640
} catch (_) {}
3741

3842
if (!isConfigFileExists) {
39-
// Default value for "root" param
40-
// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config
41-
return '/mnt/';
43+
return defaultMountPoint;
4244
}
4345

4446
const configContent = await pReadFile(configFilePath, {encoding: 'utf8'});
47+
const configMountPoint = /root\s*=\s*(.*)/g.exec(configContent);
48+
49+
if (!configMountPoint) {
50+
return defaultMountPoint;
51+
}
4552

46-
mountPoint = (/root\s*=\s*(.*)/g.exec(configContent)[1] || '').trim();
53+
mountPoint = configMountPoint[1].trim();
4754
mountPoint = mountPoint.endsWith('/') ? mountPoint : mountPoint + '/';
4855

4956
return mountPoint;

0 commit comments

Comments
 (0)
Please sign in to comment.