Skip to content

Commit c8cc4c1

Browse files
JakobJingleheimerCeres6
authored andcommitted
module: tidy code string concat → string templates
PR-URL: nodejs#55820 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 58ef304 commit c8cc4c1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/internal/modules/package_json_reader.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ function parsePackageName(specifier, base) {
230230
}
231231

232232
function getPackageJSONURL(specifier, base) {
233-
const { packageName, packageSubpath, isScoped } =
234-
parsePackageName(specifier, base);
233+
const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
235234

236235
// ResolveSelf
237236
const packageConfig = getPackageScopeConfig(base);
@@ -242,8 +241,7 @@ function getPackageJSONURL(specifier, base) {
242241
}
243242
}
244243

245-
let packageJSONUrl =
246-
new URL('./node_modules/' + packageName + '/package.json', base);
244+
let packageJSONUrl = new URL(`./node_modules/${packageName}/package.json`, base);
247245
let packageJSONPath = fileURLToPath(packageJSONUrl);
248246
let lastPath;
249247
do {
@@ -254,9 +252,10 @@ function getPackageJSONURL(specifier, base) {
254252
// Check for !stat.isDirectory()
255253
if (stat !== 1) {
256254
lastPath = packageJSONPath;
257-
packageJSONUrl = new URL((isScoped ?
258-
'../../../../node_modules/' : '../../../node_modules/') +
259-
packageName + '/package.json', packageJSONUrl);
255+
packageJSONUrl = new URL(
256+
`${isScoped ? '../' : ''}../../../node_modules/${packageName}/package.json`,
257+
packageJSONUrl,
258+
);
260259
packageJSONPath = fileURLToPath(packageJSONUrl);
261260
continue;
262261
}

0 commit comments

Comments
 (0)