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
path: root/npm.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-11-29 22:18:18 +0300
committerisaacs <i@izs.me>2010-11-29 22:18:18 +0300
commit1fe70f7cf0aebbcad463a5b432909cc3860bc61a (patch)
tree751eb3565809cfb8049fe83df295668c707d84e0 /npm.js
parent13d7966c573c1cc838b6814b66c2552e52b8ea9c (diff)
Guard against using npm programmatically wrong.
Diffstat (limited to 'npm.js')
-rw-r--r--npm.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/npm.js b/npm.js
index 1d66197b4..82a985f7c 100644
--- a/npm.js
+++ b/npm.js
@@ -89,6 +89,9 @@ var commandCache = {}
Object.keys(abbrevs).forEach(function (c) {
Object.defineProperty(npm.commands, c, { get : function () {
+ if (!loaded) throw new Error(
+ "Call npm.load(conf, cb) before using this command.\n"+
+ "See the README.md or cli.js for example usage.")
var a = npm.deref(c)
if (commandCache[a]) return commandCache[a]
return commandCache[a] = require(__dirname+"/lib/"+a)