Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2017-05-16 11:31:17 +0300
committerRebecca Turner <me@re-becca.org>2017-05-26 04:55:23 +0300
commit6abf718acb2bec4e5b312397140daded2a60db18 (patch)
tree577618c8f99306c67864397e98ef06f7b4aa52f4 /lib
parent180e2981a5a2a7c43a2b35fda73b641abfde704c (diff)
shrinkwrap: warn on incompatible lockfile version
Diffstat (limited to 'lib')
-rw-r--r--lib/install/read-shrinkwrap.js6
-rw-r--r--lib/npm.js2
-rw-r--r--lib/shrinkwrap.js3
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/install/read-shrinkwrap.js b/lib/install/read-shrinkwrap.js
index b18265bd4..5a6e4a85a 100644
--- a/lib/install/read-shrinkwrap.js
+++ b/lib/install/read-shrinkwrap.js
@@ -8,6 +8,7 @@ const inflateShrinkwrap = require('./inflate-shrinkwrap.js')
const log = require('npmlog')
const parseJSON = require('../utils/parse-json.js')
const path = require('path')
+const PKGLOCK_VERSION = require('../npm.js').lockfileVersion
const ssri = require('ssri')
const readFileAsync = BB.promisify(fs.readFile)
@@ -24,6 +25,7 @@ function readShrinkwrap (child, next) {
if (shrinkwrap && lockfile) {
log.warn('read-shrinkwrap', 'Ignoring package-lock.json because there is already an npm-shrinkwrap.json. Please use only one of the two.')
}
+ const name = shrinkwrap ? 'npm-shrinkwrap.json' : 'package-lock.json'
let parsed = null
if (shrinkwrap || lockfile) {
try {
@@ -38,9 +40,11 @@ function readShrinkwrap (child, next) {
parsed.packageIntegrity &&
!ssri.checkData(pkgJson, parsed.packageIntegrity)
) {
- let name = shrinkwrap ? 'npm-shrinkwrap.json' : 'package-lock.json'
log.info('read-shrinkwrap', `${name} will be updated because package.json does not match what it was generated against.`)
}
+ if (parsed && parsed.lockfileVersion !== PKGLOCK_VERSION) {
+ log.warn('read-shrinkwrap', `This version of npm is compatible with lockfileVersion@${PKGLOCK_VERSION}, but ${name} was generated for lockfileVersion@${parsed.lockfileVersion || 0}. I'll try to do my best with it!`)
+ }
child.package._shrinkwrap = parsed
}
).then(() => next(), next)
diff --git a/lib/npm.js b/lib/npm.js
index 37dfa6b64..7293a7d9c 100644
--- a/lib/npm.js
+++ b/lib/npm.js
@@ -64,6 +64,8 @@
}
// ***
+ npm.lockfileVersion = 1
+
npm.rollbacks = []
try {
diff --git a/lib/shrinkwrap.js b/lib/shrinkwrap.js
index c764d3837..77deb1958 100644
--- a/lib/shrinkwrap.js
+++ b/lib/shrinkwrap.js
@@ -26,14 +26,13 @@ const writeFileAtomic = require('write-file-atomic')
const PKGLOCK = 'package-lock.json'
const SHRINKWRAP = 'npm-shrinkwrap.json'
-const PKGLOCK_VERSION = 1
+const PKGLOCK_VERSION = npm.lockfileVersion
// emit JSON describing versions of all packages currently installed (for later
// use with shrinkwrap install)
shrinkwrap.usage = 'npm shrinkwrap'
module.exports = exports = shrinkwrap
-module.exports.PKGLOCK_VERSION = PKGLOCK_VERSION
function shrinkwrap (args, silent, cb) {
if (typeof cb !== 'function') {
cb = silent