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
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-03-04 07:19:35 +0300
committerisaacs <i@izs.me>2010-03-04 07:22:00 +0300
commite56dbc2cecf22cae5a55da248b5242e2f3a407cf (patch)
tree3ab115a7fe5dc1a36c51c464e2c089976368e486 /README.md
parentafe21787e9fe870986a658510889f8ba866139fc (diff)
Add the npm_lifecycle_event environment variables so that the same script can be more easily used for multiple different parts of the process.
Diffstat (limited to 'README.md')
-rw-r--r--README.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/README.md b/README.md
index 3c41bccc8..80e3ca770 100644
--- a/README.md
+++ b/README.md
@@ -101,10 +101,24 @@ Objects are flattened following this format, so if you had `{"scripts":{"install
process.env.npm_package_scripts_install = "foo.js"
+Last but not least, the `npm_lifecycle_event` environment variable is set to whichever stage of the cycle is being executed. So, you could have a single script used for different parts of the process which switches based on what's currently happening.
+
If the script exits with a code other than 0, then this will abort the process.
Note that these script files don't have to be nodejs or even javascript programs. They just have to be some kind of executable file.
+For example, if your package.json contains this:
+
+ { "scripts" :
+ { "install" : "scripts/install.js"
+ , "postinstall" : "scripts/install.js"
+ , "activate" : "scripts/install.js"
+ , "uninstall" : "scripts/uninstall.js"
+ }
+ }
+
+then the `scripts/install.js` will be called for the install, post-install, and activate stages of the lifecycle, and the `scripts/uninstall.js` would be called when the package is uninstalled.
+
## Todo
All the "core functionality" stuff above. Most immediately: