Commit 3c91e233 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by Jeremy Morrell

Test for package-lock.json

If the user has not specified a version for npm, but there is a package-lock.json we should automatically install npm 5

Fixes #422
parent e00996d5
......@@ -55,6 +55,7 @@ trap 'handle_failure' ERR
[ -e "$BUILD_DIR/node_modules" ] && PREBUILD=true || PREBUILD=false
[ -f "$BUILD_DIR/yarn.lock" ] && YARN=true || YARN=false
[ -f "$BUILD_DIR/package-lock.json" ] && NPM_LOCK=true || NPM_LOCK=false
### Failures that should be caught immediately
......@@ -106,7 +107,7 @@ install_bins() {
else
warn_node_engine "$node_engine"
install_nodejs "$node_engine" "$BUILD_DIR/.heroku/node"
install_npm "$npm_engine" "$BUILD_DIR/.heroku/node"
install_npm "$npm_engine" "$BUILD_DIR/.heroku/node" $NPM_LOCK
mcount "version.node.$(node --version)"
fi
......
......@@ -74,6 +74,13 @@ install_iojs() {
install_npm() {
local version="$1"
local dir="$2"
local npm_lock="$3"
if $npm_lock && [ "$version" == "" ]; then
echo "Detected package-lock.json: defaulting npm to version 5.x.x"
version="5.x.x"
fi
if [ "$version" == "" ]; then
echo "Using default npm version: `npm --version`"
......
{
"name": "yarn",
"version": "1.0.0",
"lockfileVersion": 1,
"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"
}
}
......@@ -119,6 +119,13 @@ testErrorYarnAndNpmLockfiles() {
assertCapturedError
}
testDefaultToNpm5() {
compile "npm-lockfile-no-version"
assertCaptured "Detected package-lock.json"
assertCaptured "Downloading and installing npm 5."
assertCapturedSuccess
}
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