Skip to content

Commit

Permalink
Fix illformed requirement error on "workspace:" dependencies (#8099)
Browse files Browse the repository at this point in the history
Co-authored-by: Landon Grindheim <landon.grindheim@gmail.com>
  • Loading branch information
deivid-rodriguez and landongrindheim authored Nov 1, 2023
1 parent 5a21b49 commit e3f0d41
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def manifest_dependencies
self.class.each_dependency(json) do |name, requirement, type|
next unless requirement.is_a?(String)

# Skip dependencies using Yarn workspace cross-references as requirements
next if requirement.start_with?("workspace:")

requirement = "*" if requirement == ""
dep = build_dependency(
file: file, type: type, name: name, requirement: requirement
Expand Down
6 changes: 6 additions & 0 deletions npm_and_yarn/spec/dependabot/npm_and_yarn/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
its(:length) { is_expected.to eq(0) }
end

context "with yarn `workspace:` requirements and no lockfile" do
let(:files) { project_dependency_files("yarn/workspace_requirements_no_lockfile") }

its(:length) { is_expected.to eq(0) }
end

context "with a package-lock.json" do
let(:files) { project_dependency_files("npm6/simple") }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "file_version_requirements_no_lockfile",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gocardless/bump-test.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/gocardless/bump-test/issues"
},
"homepage": "https://github.com/gocardless/bump-test#readme",
"dependencies": {
"ember-simple-charts": "workspace:*"
}
}

0 comments on commit e3f0d41

Please sign in to comment.