Skip to content

Commit

Permalink
module: fix check for package.json at volume root
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyBooth committed May 22, 2020
1 parent 979ec42 commit a94a5ba
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const {
SafeMap,
String,
StringPrototypeIndexOf,
StringPrototypeLastIndexOf,
StringPrototypeMatch,
StringPrototypeSlice,
StringPrototypeStartsWith,
Expand Down Expand Up @@ -286,12 +287,13 @@ function readPackageScope(checkPath) {
const rootSeparatorIndex = checkPath.indexOf(path.sep);
let separatorIndex;
while (
(separatorIndex = checkPath.lastIndexOf(path.sep)) > rootSeparatorIndex
(separatorIndex = StringPrototypeLastIndexOf(checkPath, path.sep)) >=
rootSeparatorIndex
) {
checkPath = checkPath.slice(0, separatorIndex);
if (checkPath.endsWith(path.sep + 'node_modules'))
return false;
const pjson = readPackage(checkPath);
const pjson = readPackage(checkPath + path.sep);
if (pjson) return {
path: checkPath,
data: pjson
Expand Down

0 comments on commit a94a5ba

Please sign in to comment.