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

Commit

Permalink
Fix #539 Implement configurable "onload-script"
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 30, 2011
1 parent 244ffa0 commit 63b5434
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 1 deletion.
10 changes: 10 additions & 0 deletions doc/config.md
Expand Up @@ -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.
1 change: 1 addition & 0 deletions lib/utils/default-config.js
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/parse-args.js
Expand Up @@ -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
Expand Down Expand Up @@ -72,7 +73,7 @@ exports.shorthands =
, "no-rb" : ["--no-rebuild-bundle"]
, desc : ["--description"]
, "no-desc" : ["--no-description"]
, "nv" : "--node-version"
, "nv" : ["--node-version"]
}


Expand Down
11 changes: 11 additions & 0 deletions man1/config.1
Expand Up @@ -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\.
11 changes: 11 additions & 0 deletions man1/get.1
Expand Up @@ -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\.
11 changes: 11 additions & 0 deletions man1/set.1
Expand Up @@ -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\.
5 changes: 5 additions & 0 deletions npm.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 63b5434

Please sign in to comment.