Skip to content

Commit

Permalink
Memoize getting mountPoint (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richienb committed Mar 3, 2021
1 parent bc83b32 commit 26ee3d2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Expand Up @@ -21,6 +21,8 @@ const getWslDrivesMountPoint = (() => {
// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config
const defaultMountPoint = '/mnt/';

let mountPoint;

return async function () {
if (mountPoint) {
// Return memoized mount point value
Expand All @@ -46,9 +48,10 @@ const getWslDrivesMountPoint = (() => {
return defaultMountPoint;
}

const mountPoint = configMountPoint.groups.mountPoint.trim();
mountPoint = configMountPoint.groups.mountPoint.trim();
mountPoint = mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`;

return mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`;
return mountPoint;
};
})();

Expand Down

0 comments on commit 26ee3d2

Please sign in to comment.