mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
module: fix check for package.json at volume root
Fix package.json files at the volume root so that
when they contain {"type": "module"}, they behave
as documented, like such a package.json file in
any other folder.
Fixes: https://github.com/nodejs/node/issues/33438
PR-URL: https://github.com/nodejs/node/pull/33476
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
This commit is contained in:
@@ -41,6 +41,7 @@ const {
|
||||
SafeMap,
|
||||
String,
|
||||
StringPrototypeIndexOf,
|
||||
StringPrototypeLastIndexOf,
|
||||
StringPrototypeMatch,
|
||||
StringPrototypeSlice,
|
||||
StringPrototypeStartsWith,
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user