diff options
Diffstat (limited to 'deps/npm/html/doc/misc/npm-scripts.html')
-rw-r--r-- | deps/npm/html/doc/misc/npm-scripts.html | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/deps/npm/html/doc/misc/npm-scripts.html b/deps/npm/html/doc/misc/npm-scripts.html index 43b0ca63e0..d76bba3b61 100644 --- a/deps/npm/html/doc/misc/npm-scripts.html +++ b/deps/npm/html/doc/misc/npm-scripts.html @@ -60,11 +60,11 @@ Run by the <code>npm shrinkwrap</code> command.</li> <p>Additionally, arbitrary scripts can be executed by running <code>npm run-script <stage></code>. <em>Pre</em> and <em>post</em> commands with matching names will be run for those as well (e.g. <code>premyscript</code>, <code>myscript</code>, -<code>postmyscript</code>). Scripts from dependencies can be run with `npm explore</p> -<p><pkg> -- npm run <stage>`.</p> +<code>postmyscript</code>). Scripts from dependencies can be run with <code>npm explore +<pkg> -- npm run <stage></code>.</p> <h2 id="prepublish-and-prepare">PREPUBLISH AND PREPARE</h2> <h3 id="deprecation-note">DEPRECATION NOTE</h3> -<p>Since <a href="mailto:`npm@1.1.71">`npm@1.1.71</a><code>, the npm CLI has run the</code>prepublish<code>script for both</code>npm +<p>Since <a href="mailto:%60npm@1.1.71">`npm@1.1.71</a><code>, the npm CLI has run the</code>prepublish<code>script for both</code>npm publish<code>and</code>npm install<code>, because it's a convenient way to prepare a package for use (some common use cases are described in the section below). It has also turned out to be, in practice, [very @@ -125,8 +125,7 @@ suites, then those executables will be added to the <code>PATH</code> for executing the scripts. So, if your package.json has this:</p> <pre><code>{ "name" : "foo" , "dependencies" : { "bar" : "0.1.x" } -, "scripts": { "start" : "bar ./test" } } -</code></pre><p>then you could run <code>npm start</code> to execute the <code>bar</code> script, which is +, "scripts": { "start" : "bar ./test" } }</code></pre><p>then you could run <code>npm start</code> to execute the <code>bar</code> script, which is exported into the <code>node_modules/.bin</code> directory on <code>npm install</code>.</p> <h3 id="package-json-vars">package.json vars</h3> <p>The package.json fields are tacked onto the <code>npm_package_</code> prefix. So, @@ -144,12 +143,9 @@ there is a config param of <code><name>[@<version>]:<key></cod if the package.json has this:</p> <pre><code>{ "name" : "foo" , "config" : { "port" : "8080" } -, "scripts" : { "start" : "node server.js" } } -</code></pre><p>and the server.js is this:</p> -<pre><code>http.createServer(...).listen(process.env.npm_package_config_port) -</code></pre><p>then the user could change the behavior by doing:</p> -<pre><code>npm config set foo:port 80 -</code></pre><h3 id="current-lifecycle-event">current lifecycle event</h3> +, "scripts" : { "start" : "node server.js" } }</code></pre><p>and the server.js is this:</p> +<pre><code>http.createServer(...).listen(process.env.npm_package_config_port)</code></pre><p>then the user could change the behavior by doing:</p> +<pre><code>npm config set foo:port 80</code></pre><h3 id="current-lifecycle-event">current lifecycle event</h3> <p>Lastly, the <code>npm_lifecycle_event</code> 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 @@ -157,16 +153,14 @@ based on what's currently happening.</p> <p>Objects are flattened following this format, so if you had <code>{"scripts":{"install":"foo.js"}}</code> in your package.json, then you'd see this in the script:</p> -<pre><code>process.env.npm_package_scripts_install === "foo.js" -</code></pre><h2 id="examples">EXAMPLES</h2> +<pre><code>process.env.npm_package_scripts_install === "foo.js"</code></pre><h2 id="examples">EXAMPLES</h2> <p>For example, if your package.json contains this:</p> <pre><code>{ "scripts" : { "install" : "scripts/install.js" , "postinstall" : "scripts/install.js" , "uninstall" : "scripts/uninstall.js" } -} -</code></pre><p>then <code>scripts/install.js</code> will be called for the install +}</code></pre><p>then <code>scripts/install.js</code> will be called for the install and post-install stages of the lifecycle, and <code>scripts/uninstall.js</code> will be called when the package is uninstalled. Since <code>scripts/install.js</code> is running for two different phases, it would @@ -179,8 +173,7 @@ fine:</p> , "install" : "make && make install" , "test" : "make test" } -} -</code></pre><h2 id="exiting">EXITING</h2> +}</code></pre><h2 id="exiting">EXITING</h2> <p>Scripts are run by passing the line as a script argument to <code>sh</code>.</p> <p>If the script exits with a code other than 0, then this will abort the process.</p> @@ -239,5 +232,5 @@ scripts is for compilation which must be done on the target architecture.</li> <tr><td style="width:60px;height:10px;background:rgb(237,127,127)" colspan=6> </td><td colspan=10 style="width:10px;height:10px;background:rgb(237,127,127)"> </td></tr> <tr><td colspan=5 style="width:50px;height:10px;background:#fff"> </td><td style="width:40px;height:10px;background:rgb(237,127,127)" colspan=4> </td><td style="width:90px;height:10px;background:#fff" colspan=9> </td></tr> </table> -<p id="footer">npm-scripts — npm@6.1.0</p> +<p id="footer">npm-scripts — npm@6.2.0</p> |