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

WSL: Fix mount point issue #224

Merged
merged 2 commits into from Feb 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions index.js
Expand Up @@ -19,6 +19,10 @@ Get the mount point for fixed drives in WSL.
@returns {string} The mount point.
*/
const getWslDrivesMountPoint = (() => {
// Default value for "root" param
// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config
const defaultMountPoint = '/mnt/';

let mountPoint;

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

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

const configContent = await pReadFile(configFilePath, {encoding: 'utf8'});
const configMountPoint = /root\s*=\s*(.*)/g.exec(configContent);

if (!configMountPoint) {
return defaultMountPoint;
}

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

return mountPoint;
Expand Down