summaryrefslogtreecommitdiff
path: root/deps/npm/lib/npm.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/npm.js')
-rw-r--r--deps/npm/lib/npm.js31
1 files changed, 27 insertions, 4 deletions
diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js
index 4f81015251..05749b3fd2 100644
--- a/deps/npm/lib/npm.js
+++ b/deps/npm/lib/npm.js
@@ -13,6 +13,9 @@
return
}
+ var unsupported = require('../lib/utils/unsupported.js')
+ unsupported.checkForBrokenNode()
+
var gfs = require('graceful-fs')
// Patch the global fs module here at the app level
var fs = gfs.gracefulify(require('fs'))
@@ -284,10 +287,6 @@
log.resume()
- // at this point the configs are all set.
- // go ahead and spin up the registry client.
- npm.registry = new CachingRegClient(npm.config)
-
var umask = npm.config.get('umask')
npm.modes = {
exec: parseInt('0777', 8) & (~umask),
@@ -301,6 +300,14 @@
var lp = Object.getOwnPropertyDescriptor(config, 'localPrefix')
Object.defineProperty(npm, 'localPrefix', lp)
+ config.set('scope', scopeifyScope(config.get('scope')))
+ npm.projectScope = config.get('scope') ||
+ scopeifyScope(getProjectScope(npm.prefix))
+
+ // at this point the configs are all set.
+ // go ahead and spin up the registry client.
+ npm.registry = new CachingRegClient(npm.config)
+
return cb(null, npm)
})
})
@@ -400,4 +407,20 @@
if (require.main === module) {
require('../bin/npm-cli.js')
}
+
+ function scopeifyScope (scope) {
+ return (!scope || scope[0] === '@') ? scope : ('@' + scope)
+ }
+
+ function getProjectScope (prefix) {
+ try {
+ var pkg = JSON.parse(fs.readFileSync(path.join(prefix, 'package.json')))
+ if (typeof pkg.name !== 'string') return ''
+ var sep = pkg.name.indexOf('/')
+ if (sep === -1) return ''
+ return pkg.name.slice(0, sep)
+ } catch (ex) {
+ return ''
+ }
+ }
})()