Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Put executables in ./bin
Browse files Browse the repository at this point in the history
Move towards having multiple different executables for various things.
  • Loading branch information
isaacs committed Jan 9, 2011
1 parent 609ed56 commit 1424fb3
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 57 deletions.
56 changes: 56 additions & 0 deletions bin/npm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env node
;(function () { // wrapper in case we're in module_context mode
var log = require("../lib/utils/log")
log.waitForConfig()
log.info("ok", "it worked if it ends with")

var fs = require("../lib/utils/graceful-fs")
, path = require("path")
, sys = require("../lib/utils/sys")
, npm = require("../npm")
, ini = require("../lib/utils/ini")
, rm = require("../lib/utils/rm-rf")
, errorHandler = require("../lib/utils/error-handler")

, argv = process.argv.slice(2)
, parseArgs = require("../lib/utils/parse-args")

log.verbose(argv, "cli")

var conf = parseArgs(argv)
npm.argv = conf.argv.remain
if (npm.deref(npm.argv[0])) npm.command = npm.argv.shift()
else conf.usage = true


if (conf.version) {
console.log(npm.version)
return
} else log("npm@"+npm.version, "using")
log("node@"+process.version, "using")

// make sure that this version of node works with this version of npm.
var semver = require("../lib/utils/semver")
, nodeVer = process.version
, reqVer = npm.nodeVersionRequired
if (reqVer && !semver.satisfies(nodeVer, reqVer)) {
return errorHandler(new Error(
"npm doesn't work with node " + nodeVer
+ "\nRequired: node@" + reqVer), true)
}

process.on("uncaughtException", errorHandler)

if (conf.usage && npm.command !== "help") {
npm.argv.unshift(npm.command)
npm.command = "help"
}

// now actually fire up npm and run the command.
// this is how to use npm programmatically:
conf._exit = true
npm.load(conf, function (er) {
if (er) return errorHandler(er)
npm.commands[npm.command](npm.argv, errorHandler)
})
})()
56 changes: 1 addition & 55 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,2 @@
#!/usr/bin/env node
;(function () { // wrapper in case we're in module_context mode
var log = require("./lib/utils/log")
log.waitForConfig()
log.info("ok", "it worked if it ends with")

var fs = require("./lib/utils/graceful-fs")
, path = require("path")
, sys = require("./lib/utils/sys")
, npm = require("./npm")
, ini = require("./lib/utils/ini")
, rm = require("./lib/utils/rm-rf")
, errorHandler = require("./lib/utils/error-handler")

, argv = process.argv.slice(2)
, parseArgs = require("./lib/utils/parse-args")

log.verbose(argv, "cli")

var conf = parseArgs(argv)
npm.argv = conf.argv.remain
if (npm.deref(npm.argv[0])) npm.command = npm.argv.shift()
else conf.usage = true


if (conf.version) {
console.log(npm.version)
return
} else log("npm@"+npm.version, "using")
log("node@"+process.version, "using")

// make sure that this version of node works with this version of npm.
var semver = require("./lib/utils/semver")
, nodeVer = process.version
, reqVer = npm.nodeVersionRequired
if (reqVer && !semver.satisfies(nodeVer, reqVer)) {
return errorHandler(new Error(
"npm doesn't work with node " + nodeVer
+ "\nRequired: node@" + reqVer), true)
}

process.on("uncaughtException", errorHandler)

if (conf.usage && npm.command !== "help") {
npm.argv.unshift(npm.command)
npm.command = "help"
}

// now actually fire up npm and run the command.
// this is how to use npm programmatically:
conf._exit = true
npm.load(conf, function (er) {
if (er) return errorHandler(er)
npm.commands[npm.command](npm.argv, errorHandler)
})
})()
require("./bin/npm.js")
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@
{ "mail" : "npm-@googlegroups.com"
, "web" : "http://github.com/isaacs/npm/issues"
}
, "directories" : { "doc" : "./doc", "man" : "./man1", "lib" : "./lib" }
, "bin" : { "npm" : "./cli.js" }
, "directories" : { "doc" : "./doc"
, "man" : "./man1"
, "lib" : "./lib"
, "bin" : "./bin"
}
, "main" : "npm"
, "engines" : { "node" : ">=0.2.3" }
, "scripts" : { "test" : "make test"
Expand Down

0 comments on commit 1424fb3

Please sign in to comment.