From b52a49bfb1871181b6160606b1a434373602fcbe Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Wed, 13 Nov 2024 08:05:44 +0000 Subject: [PATCH] =?UTF-8?q?module:=20tidy=20code=20string=20concat=20?= =?UTF-8?q?=E2=86=92=20string=20templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/55820 Reviewed-By: Antoine du Hamel Reviewed-By: Yagiz Nizipli Reviewed-By: Matteo Collina --- lib/internal/modules/package_json_reader.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js index 92f46ed3971341..ab9842ee53a7c8 100644 --- a/lib/internal/modules/package_json_reader.js +++ b/lib/internal/modules/package_json_reader.js @@ -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; }