Skip to content

Commit df8f3f8

Browse files
Merge pull request #8 from rosen-vladimirov/vladimirov/fix-yarn-support
fix: incorrect path is returned when yarn is used
2 parents 4a7ec4a + 2ee3c74 commit df8f3f8

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const getPathFromExecutableNameOnNonWindows = (packageName, executableName) => {
153153
match = lsLResult.match(regex);
154154

155155
if (match && match[1]) {
156-
const pathToRealExecutable = path.join(path.dirname(whichResult), match[1]);
156+
const pathToRealExecutable = fs.realpathSync(path.join(path.dirname(whichResult), match[1]));
157157

158158
// The executable is somewhere inside node_modules/<package name>/ directory,
159159
// so after we have the full path to executable, we are safe to match the path to node_modules/<package name>/ from it - that's where our module is.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "global-modules-path",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "Returns path to globally installed package",
55
"main": "./lib/index.js",
66
"scripts": {

test/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ describe("getPath", () => {
475475
return "";
476476
};
477477

478+
fs.realpathSync = (filePath) => {
479+
return filePath;
480+
};
481+
478482
childProcess.execSync = (command) => {
479483

480484
if (command.indexOf("ls -l") !== -1) {
@@ -614,4 +618,4 @@ describe("getPath", () => {
614618
assert.throws(() => index.getPath("test1", "test1"), "OS '1' is not supported");
615619
});
616620

617-
});
621+
});

0 commit comments

Comments
 (0)