Skip to content

Commit

Permalink
module: tidy code string concat → string templates
Browse files Browse the repository at this point in the history
PR-URL: #55820
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
JakobJingleheimer authored Nov 13, 2024
1 parent 598bbf4 commit b52a49b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/internal/modules/package_json_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ function parsePackageName(specifier, base) {
}

function getPackageJSONURL(specifier, base) {
const { packageName, packageSubpath, isScoped } =
parsePackageName(specifier, base);
const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);

// ResolveSelf
const packageConfig = getPackageScopeConfig(base);
Expand All @@ -242,8 +241,7 @@ function getPackageJSONURL(specifier, base) {
}
}

let packageJSONUrl =
new URL('./node_modules/' + packageName + '/package.json', base);
let packageJSONUrl = new URL(`./node_modules/${packageName}/package.json`, base);
let packageJSONPath = fileURLToPath(packageJSONUrl);
let lastPath;
do {
Expand All @@ -254,9 +252,10 @@ function getPackageJSONURL(specifier, base) {
// Check for !stat.isDirectory()
if (stat !== 1) {
lastPath = packageJSONPath;
packageJSONUrl = new URL((isScoped ?
'../../../../node_modules/' : '../../../node_modules/') +
packageName + '/package.json', packageJSONUrl);
packageJSONUrl = new URL(
`${isScoped ? '../' : ''}../../../node_modules/${packageName}/package.json`,
packageJSONUrl,
);
packageJSONPath = fileURLToPath(packageJSONUrl);
continue;
}
Expand Down

0 comments on commit b52a49b

Please sign in to comment.