From b6bd99a73f575545fbbaef95c12237c47dd32561 Mon Sep 17 00:00:00 2001 From: Forrest L Norvell Date: Thu, 5 Mar 2015 12:35:10 -0800 Subject: install: engineStrict only warns for this package --- lib/cache/add-named.js | 7 ------- lib/install.js | 24 +++++++++++++++++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/cache/add-named.js b/lib/cache/add-named.js index d81b7b0da..cb5a3fa8a 100644 --- a/lib/cache/add-named.js +++ b/lib/cache/add-named.js @@ -12,7 +12,6 @@ var path = require("path") , addRemoteTarball = require("./add-remote-tarball.js") , cachedPackageRoot = require("./cached-package-root.js") , mapToRegistry = require("../utils/map-to-registry.js") - , warnStrict = require("../utils/warn-deprecated.js")("engineStrict") module.exports = addNamed @@ -92,12 +91,6 @@ function engineFilter (data) { Object.keys(data.versions || {}).forEach(function (v) { var eng = data.versions[v].engines if (!eng) return - if (data.versions[v].engineStrict) { - warnStrict([ - "Per-package engineStrict (found in package.json for "+data.name+")", - "won't be used in npm 3+. Use the config setting `engine-strict` instead." - ], data.name) - } if (!strict && !data.versions[v].engineStrict) return if (eng.node && !semver.satisfies(nodev, eng.node, true) || eng.npm && !semver.satisfies(npmv, eng.npm, true)) { diff --git a/lib/install.js b/lib/install.js index 73580e5af..b79987147 100644 --- a/lib/install.js +++ b/lib/install.js @@ -109,6 +109,7 @@ var npm = require("./npm.js") , locker = require("./utils/locker.js") , lock = locker.lock , unlock = locker.unlock + , warnStrict = require("./utils/warn-deprecated.js")("engineStrict") , warnPeers = require("./utils/warn-deprecated.js")("peerDependencies") function install (args, cb_) { @@ -117,7 +118,7 @@ function install (args, cb_) { function cb (er, installed) { if (er) return cb_(er) - findPeerInvalid(where, function (er, problem) { + validateInstall(where, function (er, problem) { if (er) return cb_(er) if (problem) { @@ -244,11 +245,24 @@ function install (args, cb_) { }) } -function findPeerInvalid (where, cb) { - readInstalled(where, { log: log.warn, dev: true }, function (er, data) { - if (er) return cb(er) +function validateInstall (where, cb) { + readJson(path.resolve(where, 'package.json'), log.warn, function (er, data) { + if (er + && er.code !== 'ENOENT' + && er.code !== 'ENOTDIR') return cb(er) + + if (data && data.engineStrict) { + warnStrict([ + "Per-package engineStrict (found in this package's package.json) ", + "won't be used in npm 3+. Use the config setting `engine-strict` instead." + ], data.name) + } - cb(null, findPeerInvalid_(data.dependencies, [])) + readInstalled(where, { log: log.warn, dev: true }, function (er, data) { + if (er) return cb(er) + + cb(null, findPeerInvalid_(data.dependencies, [])) + }) }) } -- cgit v1.2.3