Skip to content

Commit

Permalink
Add version extract for corepack verbose and test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-sandhu committed Jan 17, 2025
1 parent 81dc28d commit b29d063
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions npm_and_yarn/spec/dependabot/npm_and_yarn/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b29d063

Please sign in to comment.