Skip to content
Browse files

Fix #539 Implement configurable "onload-script"

  • Loading branch information...
1 parent 244ffa0 commit 63b5434c4c63b6fadf446ae252485de32bf979d0 @isaacs isaacs committed Jan 30, 2011
Showing with 51 additions and 1 deletion.
  1. +10 −0 doc/config.md
  2. +1 −0 lib/utils/default-config.js
  3. +2 −1 lib/utils/parse-args.js
  4. +11 −0 man1/config.1
  5. +11 −0 man1/get.1
  6. +11 −0 man1/set.1
  7. +5 −0 npm.js
View
10 doc/config.md
@@ -369,3 +369,13 @@ An effective version of node to use when checking for "engines"
compliance.
Set to null or false to suppress engine checking altogether.
+
+## onload-script
+
+Default: false
+
+A script to run when npm loads. Use this to hook into various events in
+the npm flow in a programmatic way, even when using npm from the command
+line.
+
+If false, then don't do any onload stuff.
View
1 lib/utils/default-config.js
@@ -39,6 +39,7 @@ module.exports =
, manroot : path.join(process.execPath, "..", "..", "share", "man")
, "must-install" : true
, "node-version" : process.version
+ , "onload-script" : false
, outfd : stdio.stdoutFD
, proxy : process.env.http_proxy || null
, prune : undefined // if set to boolean false, then that means "never"
View
3 lib/utils/parse-args.js
@@ -35,6 +35,7 @@ exports.types =
, "must-install" : Boolean
, "node-version" : String
, outfd : [Number, Stream]
+ , "onload-script" : [false, String]
, proxy : url
, prune : Boolean
, "rebuild-bundle" : Boolean
@@ -72,7 +73,7 @@ exports.shorthands =
, "no-rb" : ["--no-rebuild-bundle"]
, desc : ["--description"]
, "no-desc" : ["--no-description"]
- , "nv" : "--node-version"
+ , "nv" : ["--node-version"]
}
View
11 man1/config.1
@@ -470,3 +470,14 @@ compliance\.
.
.P
Set to null or false to suppress engine checking altogether\.
+.
+.SH "onload\-script"
+Default: false
+.
+.P
+A script to run when npm loads\. Use this to hook into various events in
+the npm flow in a programmatic way, even when using npm from the command
+line\.
+.
+.P
+If false, then don\'t do any onload stuff\.
View
11 man1/get.1
@@ -470,3 +470,14 @@ compliance\.
.
.P
Set to null or false to suppress engine checking altogether\.
+.
+.SH "onload\-script"
+Default: false
+.
+.P
+A script to run when npm loads\. Use this to hook into various events in
+the npm flow in a programmatic way, even when using npm from the command
+line\.
+.
+.P
+If false, then don\'t do any onload stuff\.
View
11 man1/set.1
@@ -470,3 +470,14 @@ compliance\.
.
.P
Set to null or false to suppress engine checking altogether\.
+.
+.SH "onload\-script"
+Default: false
+.
+.P
+A script to run when npm loads\. Use this to hook into various events in
+the npm flow in a programmatic way, even when using npm from the command
+line\.
+.
+.P
+If false, then don\'t do any onload stuff\.
View
5 npm.js
@@ -128,12 +128,17 @@ npm.load = function (conf, cb_) {
if (loaded) return cb()
if (loading) return
loading = true
+ var onload = true
function cb (er) {
loaded = true
loadListeners.forEach(function (cb) {
process.nextTick(function () { cb(er, npm) })
})
loadListeners.length = 0
+ if (onload = onload && npm.config.get("onload-script")) {
+ require(onload)
+ onload = false
+ }
}
log.waitForConfig()
which(process.argv[0], function (er, node) {

0 comments on commit 63b5434

Please sign in to comment.
Something went wrong with that request. Please try again.