corrade-nucleus-nucleons – Blame information for rev 36
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
36 | office | 1 | # cross-spawn |
2 | |||
3 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Build status][appveyor-image]][appveyor-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] |
||
4 | |||
5 | [npm-url]:https://npmjs.org/package/cross-spawn |
||
6 | [downloads-image]:http://img.shields.io/npm/dm/cross-spawn.svg |
||
7 | [npm-image]:http://img.shields.io/npm/v/cross-spawn.svg |
||
8 | [travis-url]:https://travis-ci.org/IndigoUnited/node-cross-spawn |
||
9 | [travis-image]:http://img.shields.io/travis/IndigoUnited/node-cross-spawn/master.svg |
||
10 | [appveyor-url]:https://ci.appveyor.com/project/satazor/node-cross-spawn |
||
11 | [appveyor-image]:https://img.shields.io/appveyor/ci/satazor/node-cross-spawn/master.svg |
||
12 | [david-dm-url]:https://david-dm.org/IndigoUnited/node-cross-spawn |
||
13 | [david-dm-image]:https://img.shields.io/david/IndigoUnited/node-cross-spawn.svg |
||
14 | [david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-cross-spawn#info=devDependencies |
||
15 | [david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/node-cross-spawn.svg |
||
16 | |||
17 | A cross platform solution to node's spawn and spawnSync. |
||
18 | |||
19 | |||
20 | ## Installation |
||
21 | |||
22 | `$ npm install cross-spawn` |
||
23 | |||
24 | If you are using `spawnSync` on node 0.10 or older, you will also need to install `spawn-sync`: |
||
25 | |||
26 | `$ npm install spawn-sync` |
||
27 | |||
28 | |||
29 | ## Why |
||
30 | |||
31 | Node has issues when using spawn on Windows: |
||
32 | |||
33 | - It ignores [PATHEXT](https://github.com/joyent/node/issues/2318) |
||
34 | - It does not support [shebangs](http://pt.wikipedia.org/wiki/Shebang) |
||
35 | - It does not allow you to run `del` or `dir` |
||
36 | - It does not properly escape arguments with spaces or special characters |
||
37 | |||
38 | All these issues are handled correctly by `cross-spawn`. |
||
39 | There are some known modules, such as [win-spawn](https://github.com/ForbesLindesay/win-spawn), that try to solve this but they are either broken or provide faulty escaping of shell arguments. |
||
40 | |||
41 | |||
42 | ## Usage |
||
43 | |||
44 | Exactly the same way as node's [`spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) or [`spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options), so it's a drop in replacement. |
||
45 | |||
46 | ```javascript |
||
47 | var spawn = require('cross-spawn'); |
||
48 | |||
49 | // Spawn NPM asynchronously |
||
50 | var child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' }); |
||
51 | |||
52 | // Spawn NPM synchronously |
||
53 | var results = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' }); |
||
54 | ``` |
||
55 | |||
56 | ## Caveat |
||
57 | |||
58 | On Windows, cross-spawn will only spawn `cmd.exe` if necessary. If the extension |
||
59 | of the executable is `.exe` or `.com`, it will spawn it directly. If you wish |
||
60 | to override this behavior and *always* spawn a shell, pass the `{shell: true}` |
||
61 | option. |
||
62 | |||
63 | |||
64 | ## Tests |
||
65 | |||
66 | `$ npm test` |
||
67 | |||
68 | |||
69 | ## License |
||
70 | |||
71 | Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php). |