diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb index 7470120b79..b65a75752a 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb @@ -80,6 +80,10 @@ def clean_version(version) # Matches @ followed by x.y.z (digits separated by dots) if (match = version.match(/@(\d+\.\d+\.\d+)/)) version = match[1] # Just "4.5.3" + + # Extract version in case the output contains Corepack verbose data + elsif version.include?("Corepack") + version = T.must(version.match(/[\r\n](\d+\.\d+\.\d+))) end version = version&.gsub(/^v/, "") end diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/version_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/version_spec.rb index 8a05ccea7d..46f43ef2ed 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/version_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/version_spec.rb @@ -317,5 +317,13 @@ it { is_expected.to be(true) } end + + context "with corepack returning a additional info with version string" do + let(:requirement) { Gem::Requirement.new("4.6.0") } + let(:version_string) { "Corepack is about to download " \ + "https://repo.yarnpkg.com/4.6.0/packages/yarnpkg-cli/bin/yarn.js 4.6.0" } + + it { is_expected.to be(true) } + end end end