You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: fix certain arguments not being correctly escaped or causing batch syntax error
More specifically:
- Fix a bug that made it impossible to escape an argument that contained quotes followed by `>` or other special chars, e.g.: `"foo|bar"`, fixes#82
- Fix a bug were a command containing `%x%` would be replaced with the contents of the `x` environment variable, fixes#51
This was resolved by using `^` to escape all meta chars.
Additionally, double escaping was necessary for cmd-shim files located in `node_modules./bin/`.
Also, this commit was a major overhaul:
- Upgrade tooling
- Upgrate project to es6 (node v4)
- Fix commands as posix unix relatixe paths not working correctly
- Fix `options` argument being mutated
- Improve compliance with node's ENOENT errors
- Improve detection of node's shell option support
- Migrate project to moxystudio
BREAKING CHANGE: remove support for older nodejs versions, only node >= 4 is supported
Fixes#82, #51
Copy file name to clipboardExpand all lines: CHANGELOG.md
+18-1
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,21 @@
1
-
## 5.0.0 - 2016-10-30
1
+
# Change Log
2
+
3
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com./conventional-changelog/standard-version) for commit guidelines.
- Fix `options.shell` support for NodeJS [v4.8](https://github.com./nodejs/node/blob/master/doc/changelogs/CHANGELOG_V4.md#4.8.0)
A cross platform solution to node's spawn and spawnSync.
@@ -23,10 +23,6 @@ A cross platform solution to node's spawn and spawnSync.
23
23
24
24
`$ npm install cross-spawn`
25
25
26
-
If you are using `spawnSync` on node 0.10 or older, you will also need to install `spawn-sync`:
27
-
28
-
`$ npm install spawn-sync`
29
-
30
26
31
27
## Why
32
28
@@ -35,7 +31,9 @@ Node has issues when using spawn on Windows:
35
31
- It ignores [PATHEXT](https://github.com./joyent/node/issues/2318)
36
32
- It does not support [shebangs](http://pt.wikipedia.org/wiki/Shebang)
37
33
- No `options.shell` support on node `<v4.8`
38
-
- It does not allow you to run `del` or `dir`
34
+
- Has problems running commands with [spaces](https://github.com./nodejs/node/issues/7367)
35
+
- Has problems running commands with posix relative paths (e.g.: `my-folder/my-executable`)
36
+
- Circuvents an [issue](https://github.com./moxystudio/node-cross-spawn/issues/82) around command shims (files in node_modules/.bin/), where arguments with quotes and parenthesis would result in an [invalid syntax error](ADD_LINK_TO_TESTS)
39
37
40
38
All these issues are handled correctly by `cross-spawn`.
41
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.
####`options.shell` as an alternative to `cross-spawn`
60
+
###Using`options.shell` as an alternative to `cross-spawn`
63
61
64
62
Starting from node `v4.8`, `spawn` has a `shell` option that allows you run commands from within a shell. This new option solves most of the problems that `cross-spawn` attempts to solve, but:
65
63
66
64
- It's not supported in node `<v4.8`
67
-
- It has no support for shebangs on Windows
68
65
- You must manually escape the command and arguments which is very error prone, specially when passing user input
66
+
- It just solves the [PATHEXT](https://github.com./joyent/node/issues/2318) issue from the [Why](#why) section
69
67
70
68
If you are using the `shell` option to spawn a command in a cross platform way, consider using `cross-spawn` instead. You have been warned.
71
69
70
+
### `options.shell` support
71
+
72
+
While `cross-spawn` adds support for `options.shell` in node `<v4.8`, all of its enhancements are disabled.
73
+
74
+
This mimics the Node.js behavior. More specifically, the command and its arguments will not be automatically escaped nor shebang support will be offered. This is by design because if you are using `options.shell` you are probably targeting a specific platform anyway and you don't want things to get into your way.
72
75
73
-
####Shebangs
76
+
### Shebangs support
74
77
75
-
While `cross-spawn` handles shebangs on Windows, its support is limited: e.g.: it doesn't handle arguments after the path, e.g.: `#!/bin/bash -e`.
78
+
While `cross-spawn` handles shebangs on Windows, its support is limited. More specifically, it just supports `#!/usr/bin/env <program>` where `<program>` must not contain any arguments.
79
+
If you would like to have the shebang support improved, feel free to contribute via a pull-request.
0 commit comments