Commit 4167b383 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Error out when two different lockfiles are present in the repo (#411)

Error out when two different lockfiles are present in the repo

Fixes #410
parent e04e772e
......@@ -61,6 +61,7 @@ trap 'handle_failure' ERR
fail_dot_heroku "$BUILD_DIR"
fail_dot_heroku_node "$BUILD_DIR"
fail_invalid_package_json "$BUILD_DIR"
fail_yarn_and_npm_lockfiles "$BUILD_DIR"
warn_prebuilt_modules "$BUILD_DIR"
warn_missing_package_json "$BUILD_DIR"
......
......@@ -63,6 +63,31 @@ fail_dot_heroku_node() {
fi
}
fail_yarn_and_npm_lockfiles() {
if [ -f "${1:-}/yarn.lock" ] && [ -f "${1:-}/package-lock.json" ]; then
mcount "failures.two-lock-files"
header "Build failed"
warn "Two different lock files found: package-lock.json and yarn.lock
Both npm and yarn have created lock files for this application,
but only one can be used to install dependencies. Installing
dependencies using the wrong package manager can result in missing
packages or subtle bugs in production.
- To use npm to install your application's dependencies please delete
the yarn.lock file.
$ git rm yarn.lock
- To use yarn to install your application's dependences please delete
the package-lock.json file.
$ git rm package-lock.json
" https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-conflicting-lock-files
exit 1
fi
}
warning() {
local tip=${1:-}
local url=${2:-https://devcenter.heroku.com/articles/nodejs-support}
......
{
"name": "yarn",
"version": "1.0.0",
"lockfileVersion": 1,
"packageIntegrity": "sha512-4+lHSm8TaNvPyMeXgKHJuEJTZ7e9GkTnM2diAM0bJGwaayn7IfeF0M/COETD9Np6vuSjqraOuBlw+i5B2EYTKA==",
"dependencies": {
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
}
}
}
{
"name": "yarn",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"lodash": "^4.16.4"
}
}
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lodash:
version "4.16.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.4.tgz#01ce306b9bad1319f2a5528674f88297aeb70127"
......@@ -110,6 +110,15 @@ testYarnOnlyEngine() {
assertCapturedSuccess
}
testErrorYarnAndNpmLockfiles() {
compile "yarn-and-npm-lockfiles"
assertNotCaptured "Creating runtime environment"
assertCaptured "Two different lock files found: package-lock.json and yarn.lock"
assertCaptured "Both npm and yarn have created lock files"
assertCaptured "https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-conflicting-lock-files"
assertCapturedError
}
testWarnUnmetDepNpm() {
compile "unmet-dep"
assertCaptured "fail npm install"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment