Skip to content

Commit

Permalink
NPM: handle EBADENGINE better (dependabot#7194)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman committed Apr 28, 2023
1 parent 944295d commit 1eb0774
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ def handle_npm_updater_error(error)
raise Dependabot::DependencyFileNotParseable, msg
end

if error_message.include?("EBADENGINE")
msg = "Dependabot uses Node.js #{`node --version`} and NPM #{`npm --version`}. " \
"Due to the engine-strict setting, the update will not succeed."
raise Dependabot::DependencyFileNotResolvable, msg
end

raise error
end
# rubocop:enable Metrics/AbcSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@
end
end

context "with engines-strict and a version that won't work with Dependabot" do
let(:files) { project_dependency_files("npm8/engines") }

it "raises a helpful error" do
expect { updated_npm_lock_content }.
to raise_error(Dependabot::DependencyFileNotResolvable)
end
end

context "when the lockfile does not have indentation" do
let(:files) { project_dependency_files("npm8/simple_no_indentation") }

Expand Down
1 change: 1 addition & 0 deletions npm_and_yarn/spec/fixtures/projects/npm8/engines/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
164 changes: 164 additions & 0 deletions npm_and_yarn/spec/fixtures/projects/npm8/engines/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions npm_and_yarn/spec/fixtures/projects/npm8/engines/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "{{ name }}",
"engines": {
"node": "512",
"npm": "256"
},
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no\\ test\ specified\" && exit 1",
"prettify": "prettier --write \"{{packages/*/src,examples,cypress,scripts}/**/,}*.{js,jsx,ts,tsx,css,md}\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/waltfy/PROTO_TEST.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/waltfy/PROTO_TEST/issues"
},
"homepage": "https://github.com/waltfy/PROTO_TEST#readme",
"dependencies": {
"fetch-factory": "^0.0.1"
},
"devDependencies": {
"etag" : "^1.0.0"
}}

0 comments on commit 1eb0774

Please sign in to comment.