@@ -97,91 +97,6 @@ more easily.
9797If you have strong feelings about package managers, I'd love to hear your
9898opinions.
9999
100-
101- ## What works now:
102-
103- These are the commands that actually do things, as of today. If they don't do
104- what they say they do, then please [ post an issue] ( http://github.com/isaacs/npm/issues )
105- about it.
106-
107- ## Package Lifecycle Scripts
108-
109- npm supports the "scripts" member of the package.json script, for the
110- following scripts:
111-
112- ` preinstall ` - Run BEFORE the package is installed
113-
114- ` install ` - Run AFTER the package is installed.
115-
116- ` preactivate ` - Run BEFORE the package is activated.
117-
118- ` activate ` - Run AFTER the package has been activated.
119-
120- ` deactivate ` - Run BEFORE the package is deactivated.
121-
122- ` postdeactivate ` - Run AFTER the package is deactivated.
123-
124- ` uninstall ` - Run BEFORE the package is uninstalled.
125-
126- ` postuninstall ` - Run AFTER the package is uninstalled.
127-
128- ### Package Lifecycle Env Vars
129-
130- Package scripts are run in an environment where the package.json fields have
131- been tacked onto the ` npm_package_ ` prefix. So, for instance, if you had
132- ` {"name":"foo", "version":"1.2.5"} ` in your package.json file, then in your
133- various lifecycle scripts, this would be true:
134-
135- process.env.npm_package_name === "foo"
136- process.env.npm_package_version === "1.2.5"
137-
138- Objects are flattened following this format, so if you had
139- ` {"scripts":{"install":"foo.js"}} ` in your package.json, then you'd see this
140- in the script:
141-
142- process.env.npm_package_scripts_install = "foo.js"
143-
144- Last but not least, the ` npm_lifecycle_event ` environment variable is set to
145- whichever stage of the cycle is being executed. So, you could have a single
146- script used for different parts of the process which switches based on what's
147- currently happening.
148-
149- If the script exits with a code other than 0, then this will abort the
150- process.
151-
152- Note that these script files don't have to be nodejs or even javascript
153- programs. They just have to be some kind of executable file.
154-
155- For example, if your package.json contains this:
156-
157- { "scripts" :
158- { "install" : "scripts/install.js"
159- , "postinstall" : "scripts/install.js"
160- , "activate" : "scripts/install.js"
161- , "uninstall" : "scripts/uninstall.js"
162- }
163- }
164-
165- then the ` scripts/install.js ` will be called for the install, post-install,
166- and activate stages of the lifecycle, and the ` scripts/uninstall.js ` would be
167- called when the package is uninstalled. Since ` scripts/install.js ` is running
168- for three different phases, it would be wise in this case to look at the
169- ` npm_lifecycle_event ` environment variable.
170-
171- If you want to run a make command, you can do so. This works just fine:
172-
173- { "scripts" :
174- { "preinstall" : "./configure"
175- , "install" : "make"
176- , "test" : "make test"
177- }
178- }
179-
180- However, the script line is not simply a command line, so ` make && make install `
181- would try to execute the ` make ` command with the arguments ` && ` , ` make ` , and
182- ` install ` . If you have a lot of stuff to run in a command, put it in a script
183- file.
184-
185100## Deviations from and Extensions to the Packages/1.0 Spec
186101
187102npm aims to implement the commonjs
0 commit comments