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 <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
JakobJingleheimer authored and aduh95 committed Nov 16, 2024
1 parent c5afdaf commit 11e1bdd
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 11e1bdd

Please sign in to comment.