You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # cross-spawn
  2. [![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]
  3. [npm-url]:https://npmjs.org/package/cross-spawn
  4. [downloads-image]:http://img.shields.io/npm/dm/cross-spawn.svg
  5. [npm-image]:http://img.shields.io/npm/v/cross-spawn.svg
  6. [travis-url]:https://travis-ci.org/IndigoUnited/node-cross-spawn
  7. [travis-image]:http://img.shields.io/travis/IndigoUnited/node-cross-spawn/master.svg
  8. [appveyor-url]:https://ci.appveyor.com/project/satazor/node-cross-spawn
  9. [appveyor-image]:https://img.shields.io/appveyor/ci/satazor/node-cross-spawn/master.svg
  10. [david-dm-url]:https://david-dm.org/IndigoUnited/node-cross-spawn
  11. [david-dm-image]:https://img.shields.io/david/IndigoUnited/node-cross-spawn.svg
  12. [david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-cross-spawn#info=devDependencies
  13. [david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/node-cross-spawn.svg
  14. A cross platform solution to node's spawn and spawnSync.
  15. ## Installation
  16. `$ npm install cross-spawn`
  17. If you are using `spawnSync` on node 0.10 or older, you will also need to install `spawn-sync`:
  18. `$ npm install spawn-sync`
  19. ## Why
  20. Node has issues when using spawn on Windows:
  21. - It ignores [PATHEXT](https://github.com/joyent/node/issues/2318)
  22. - It does not support [shebangs](http://pt.wikipedia.org/wiki/Shebang)
  23. - It does not allow you to run `del` or `dir`
  24. - It does not properly escape arguments with spaces or special characters
  25. All these issues are handled correctly by `cross-spawn`.
  26. 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.
  27. ## Usage
  28. 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.
  29. ```javascript
  30. var spawn = require('cross-spawn');
  31. // Spawn NPM asynchronously
  32. var child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
  33. // Spawn NPM synchronously
  34. var results = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
  35. ```
  36. ## Tests
  37. `$ npm test`
  38. ## License
  39. Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).