"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/bin/npm-cli.js" (7 Feb 2017, 1996 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env node
    2 ;(function () { // wrapper in case we're in module_context mode
    3   // windows: running "npm blah" in this folder will invoke WSH, not node.
    4   /*global WScript*/
    5   if (typeof WScript !== 'undefined') {
    6     WScript.echo(
    7       'npm does not work when run\n' +
    8         'with the Windows Scripting Host\n\n' +
    9         "'cd' to a different directory,\n" +
   10         "or type 'npm.cmd <args>',\n" +
   11         "or type 'node npm <args>'."
   12     )
   13     WScript.quit(1)
   14     return
   15   }
   16 
   17   process.title = 'npm'
   18 
   19   var log = require('npmlog')
   20   log.pause() // will be unpaused when config is loaded.
   21 
   22   log.info('it worked if it ends with', 'ok')
   23 
   24   var path = require('path')
   25   var npm = require('../lib/npm.js')
   26   var npmconf = require('../lib/config/core.js')
   27   var errorHandler = require('../lib/utils/error-handler.js')
   28 
   29   var configDefs = npmconf.defs
   30   var shorthands = configDefs.shorthands
   31   var types = configDefs.types
   32   var nopt = require('nopt')
   33 
   34   // if npm is called as "npmg" or "npm_g", then
   35   // run in global mode.
   36   if (path.basename(process.argv[1]).slice(-1) === 'g') {
   37     process.argv.splice(1, 1, 'npm', '-g')
   38   }
   39 
   40   log.verbose('cli', process.argv)
   41 
   42   var conf = nopt(types, shorthands)
   43   npm.argv = conf.argv.remain
   44   if (npm.deref(npm.argv[0])) npm.command = npm.argv.shift()
   45   else conf.usage = true
   46 
   47   if (conf.version) {
   48     console.log(npm.version)
   49     return
   50   }
   51 
   52   if (conf.versions) {
   53     npm.command = 'version'
   54     conf.usage = false
   55     npm.argv = []
   56   }
   57 
   58   log.info('using', 'npm@%s', npm.version)
   59   log.info('using', 'node@%s', process.version)
   60 
   61   process.on('uncaughtException', errorHandler)
   62 
   63   if (conf.usage && npm.command !== 'help') {
   64     npm.argv.unshift(npm.command)
   65     npm.command = 'help'
   66   }
   67 
   68   // now actually fire up npm and run the command.
   69   // this is how to use npm programmatically:
   70   conf._exit = true
   71   npm.load(conf, function (er) {
   72     if (er) return errorHandler(er)
   73     npm.commands[npm.command](npm.argv, errorHandler)
   74   })
   75 })()