Unverified Commit 1d3fc338 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Dont replace npm because of lockfile if npm is already >= 5 (#499)

parent b9adc5f7
...@@ -69,8 +69,11 @@ install_npm() { ...@@ -69,8 +69,11 @@ install_npm() {
local version="$1" local version="$1"
local dir="$2" local dir="$2"
local npm_lock="$3" local npm_lock="$3"
local npm_version="$(npm --version)"
if $npm_lock && [ "$version" == "" ]; then # If the user has not specified a version of npm, but has an npm lockfile
# upgrade them to npm 5.x if a suitable version was not installed with Node
if $npm_lock && [ "$version" == "" ] && [ "${npm_version:0:1}" -lt "5" ]; then
echo "Detected package-lock.json: defaulting npm to version 5.x.x" echo "Detected package-lock.json: defaulting npm to version 5.x.x"
version="5.x.x" version="5.x.x"
fi fi
......
...@@ -5,5 +5,8 @@ ...@@ -5,5 +5,8 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"lodash": "^4.16.4" "lodash": "^4.16.4"
},
"engines": {
"node": "8.9.1"
} }
} }
{
"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"
},
"engines": {
"node": "6.9.5"
}
}
...@@ -189,8 +189,16 @@ testYarnLockfileOutOfDate() { ...@@ -189,8 +189,16 @@ testYarnLockfileOutOfDate() {
testDefaultToNpm5() { testDefaultToNpm5() {
compile "npm-lockfile-no-version" compile "npm-lockfile-no-version"
assertCaptured "Using default npm version"
assertCaptured "Installing node modules (package.json + package-lock)"
assertCapturedSuccess
}
testDefaultToNpm5WithNode6() {
compile "npm-lockfile-node-6-no-version"
assertCaptured "Detected package-lock.json" assertCaptured "Detected package-lock.json"
assertCaptured "Bootstrapping npm 5" assertCaptured "Bootstrapping npm 5"
assertCaptured "Installing node modules (package.json + package-lock)"
assertCapturedSuccess assertCapturedSuccess
} }
......
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