Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def yarn_lockfile_details(lockfile, dependency_name, requirement, _manifest_name
details_candidates.first.last
else
details_candidates.find do |k, _|
k.split(/(?<=\w)\@/)[1..-1].join("@") == requirement
k.scan(/(?<=\w)\@(?:npm:)?([^\s,]+)/).flatten.include?(requirement)
end&.last
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,24 @@
it { is_expected.to eq(nil) }
end
end

context "that have multiple requirements" do
let(:dependency_files) { project_dependency_files("yarn_berry/multiple_requirements") }
let(:dependency_name) { "postcss" }
let(:requirement) { "^8.4.17" }

it "finds the one matching the requirement" do
expect(lockfile_details).to eq(
"version" => "8.4.17",
"resolution" => "postcss@npm:8.4.17",
"dependencies" => { "nanoid" => "^3.3.4", "picocolors" => "^1.0.0", "source-map-js" => "^1.0.2" },
"checksum" => "a6d9096dd711e17f7b1d18ff5dcb4fdedf3941d5a3dc8b0e4ea" \
"873b8f31972d57f73d6da9a8aed7ff389eb52190ed34f6a94f299a7f5ddc68b08a24a48f77eb9",
"languageName" => "node",
"linkType" => "hard"
)
end
end
end

context "for npm lockfiles" do
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "{{ name }}",
"dependencies": {
"next": "^12.3.1"
},
"devDependencies": {
"eslint-plugin-tailwindcss": "^3.6.2",
"postcss": "^8.4.17"
},
"packageManager": "yarn@3.2.3"
}
Loading