Skip to content

Commit 021b174

Browse files
JakobJingleheimeraduh95
authored andcommitted
module: tidy code string concat → string templates
PR-URL: #55820 Reviewed-By: Antoine du Hamel Reviewed-By: Yagiz Nizipli Reviewed-By: Matteo Collina
1 parent 6ffb66f commit 021b174

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/internal/modules/package_json_reader.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ function parsePackageName(specifier, base) {
219219
}
220220

221221
function getPackageJSONURL(specifier, base) {
222-
const { packageName, packageSubpath, isScoped } =
223-
parsePackageName(specifier, base);
222+
const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
224223

225224
// ResolveSelf
226225
const packageConfig = getPackageScopeConfig(base);
@@ -231,8 +230,7 @@ function getPackageJSONURL(specifier, base) {
231230
}
232231
}
233232

234-
let packageJSONUrl =
235-
new URL('./node_modules/' + packageName + '/package.json', base);
233+
let packageJSONUrl = new URL(`./node_modules/${packageName}/package.json`, base);
236234
let packageJSONPath = fileURLToPath(packageJSONUrl);
237235
let lastPath;
238236
do {
@@ -243,9 +241,10 @@ function getPackageJSONURL(specifier, base) {
243241
// Check for !stat.isDirectory()
244242
if (stat !== 1) {
245243
lastPath = packageJSONPath;
246-
packageJSONUrl = new URL((isScoped ?
247-
'../../../../node_modules/' : '../../../node_modules/') +
248-
packageName + '/package.json', packageJSONUrl);
244+
packageJSONUrl = new URL(
245+
`${isScoped ? '../' : ''}../../../node_modules/${packageName}/package.json`,
246+
packageJSONUrl,
247+
);
249248
packageJSONPath = fileURLToPath(packageJSONUrl);
250249
continue;
251250
}

0 commit comments

Comments
 (0)