global-install.js 656 B

123456789101112131415161718
  1. 'use strict'
  2. var path = require('path')
  3. var npm = require('../../npm.js')
  4. var Installer = require('../../install.js').Installer
  5. var packageId = require('../../utils/package-id.js')
  6. var moduleName = require('../../utils/module-name.js')
  7. module.exports = function (staging, pkg, log, next) {
  8. log.silly('global-install', packageId(pkg))
  9. var globalRoot = path.resolve(npm.globalDir, '..')
  10. npm.config.set('global', true)
  11. var install = new Installer(globalRoot, false, [moduleName(pkg) + '@' + pkg.package._requested.rawSpec])
  12. install.link = false
  13. install.run(function () {
  14. npm.config.set('global', false)
  15. next.apply(null, arguments)
  16. })
  17. }