From 0f412bb7963dcf01a83158054c553ed8a8db2c69 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Honey Date: Tue, 8 Aug 2023 15:04:41 -0700 Subject: [PATCH 1/2] Fixing Yarn1 erroring on parent npmrc files with undefined vars --- .../npm_and_yarn/file_updater/yarn_lockfile_updater.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb index aee6883934c..14c4dce3b3c 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb @@ -380,9 +380,12 @@ def clean_npmrc_in_path(yarn_lock) dirs.pop while dirs.any? npmrc = dirs.join("/") + "/.npmrc" - break unless File.exist?(npmrc) - File.write(npmrc, File.read(npmrc).gsub(/\$\{.*\}/, "")) + if File.exist?(npmrc) + # If the .npmrc file exists, clean it + File.write(npmrc, File.read(npmrc).gsub(/\$\{.*?\}/, "")) + end + dirs.pop end end From 642c17bbc7ae799889f45610ece44749ea406126 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Honey Date: Tue, 8 Aug 2023 15:29:40 -0700 Subject: [PATCH 2/2] removed unwanted spaces --- .../npm_and_yarn/file_updater/yarn_lockfile_updater.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb index 14c4dce3b3c..dbfb183df0c 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb @@ -380,12 +380,10 @@ def clean_npmrc_in_path(yarn_lock) dirs.pop while dirs.any? npmrc = dirs.join("/") + "/.npmrc" - if File.exist?(npmrc) # If the .npmrc file exists, clean it File.write(npmrc, File.read(npmrc).gsub(/\$\{.*?\}/, "")) end - dirs.pop end end