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
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-07-01 08:45:10 +0300
committerRebecca Turner <me@re-becca.org>2015-07-01 14:22:59 +0300
commitd2239b823cf2627b6356bb796fbbed96121993b5 (patch)
tree73036ebbbbdddab6710dc1112957bb762d397653
parent68da583a6ef2b35ec3b13dbbb64678dfdb70934e (diff)
install: determine globalness based on install dir not config
PR-URL: https://github.com/npm/npm/pull/8782
-rw-r--r--lib/install.js27
-rw-r--r--lib/ls.js4
2 files changed, 24 insertions, 7 deletions
diff --git a/lib/install.js b/lib/install.js
index c29ec5e9a..db01693bc 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -160,16 +160,17 @@ function install (where, args, cb) {
args = where
where = null
}
+ var globalTop = path.resolve(npm.globalDir, '..')
if (!where) {
where = npm.config.get('global')
- ? path.resolve(npm.globalDir, '..')
+ ? globalTop
: npm.prefix
}
validate('SAF', [where, args, cb])
// the /path/to/node_modules/..
var dryrun = !!npm.config.get('dry-run')
- if (npm.config.get('global') && !args.length) {
+ if (where === globalTop && !args.length) {
args = ['.']
}
args = args.filter(function (a) {
@@ -195,12 +196,30 @@ function Installer (where, dryrun, args) {
this.dev = npm.config.get('dev') || !npm.config.get('production')
this.rollback = npm.config.get('rollback')
this.link = npm.config.get('link')
+ this.global = this.where === path.resolve(npm.globalDir, '..')
}
Installer.prototype = {}
Installer.prototype.run = function (cb) {
validate('F', arguments)
+ // FIXME: This is bad and I should feel bad.
+ // lib/install needs to have some way of sharing _limited_
+ // state with the things it calls. Passing the object is too
+ // much. The global config is WAY too much. =( =(
+ // But not having this is gonna break linked modules in
+ // subtle stupid ways, and refactoring all this code isn't
+ // the right thing to do just yet.
+ if (this.global) {
+ var prevGlobal = npm.config.get('global')
+ npm.config.set('global', true)
+ var next = cb
+ cb = function () {
+ npm.config.set('global', prevGlobal)
+ next.apply(null, arguments)
+ }
+ }
+
var installSteps = []
var postInstallSteps = []
installSteps.push(
@@ -323,7 +342,7 @@ Installer.prototype.loadAllDepsIntoIdealTree = function (cb) {
if (installNewModules) {
steps.push([loadRequestedDeps, this.args, this.idealTree, saveDeps, cg.newGroup('loadRequestedDeps')])
- if (npm.config.get('global')) {
+ if (this.global) {
steps.push([this, this.filterGlobalTrees])
}
} else {
@@ -369,7 +388,7 @@ Installer.prototype.generateActionsToTake = function (cb) {
Installer.prototype.computeLinked = function (cb) {
validate('F', arguments)
- if (!this.link || npm.config.get('global')) return cb()
+ if (!this.link || this.global) return cb()
var linkTodoList = []
var self = this
asyncMap(this.differences, function (action, next) {
diff --git a/lib/ls.js b/lib/ls.js
index 4d86d1ac2..3903c5a13 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -142,9 +142,7 @@ function getLite (data, noname) {
if (data.extraneous) {
lite.extraneous = true
lite.problems = lite.problems || []
- lite.problems.push('extraneous: ' +
- data.name + '@' + data.version +
- ' ' + (data.path || ''))
+ lite.problems.push('extraneous: ' + data._id + ' ' + (data.path || ''))
}
if (data._from) {