module: tidy code string concat → string templates

PR-URL: https://github.com/nodejs/node/pull/55820
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Jacob Smith 2024-11-13 08:05:44 +00:00 committed by GitHub
parent 598bbf4833
commit b52a49bfb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
@ -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 {
@ -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;
}