* Remove separate "internal error" from exec
* Fix unknown command error regex
* Add message about command not found regex
* Silence errors while reading files in exec
The stdout and stderr files may never be opened or written to in certain
circumstances. In particular, if the timeout is short enough, the child
node process does not have enough time to start, and the child script
does not execute, so the files are not written to. So, catch errors form
trying to read the files, and ignore them.
* Do not silence errors due to short timeouts
* Simplify test regex for missing command
* Default error code to 1 if not set
This reverts commit 64d5899abc86dd7b7fa84455c0ce3551786c4b5b.
Reason for revert: If stdin is large, then the param object can become
an extremely long string, exceeding the maximum OS size limit on
commandline parameters.
Original change's description:
> refactor(exec): remove paramsFile (#807)
>
> The `paramsFile` is obsolete now that we use `execFileSync()` for our
> internal implementation. Instead, we pass parameters to the child
> process directly as a single commandline parameter to reduce file I/O.
>
> Issue #782Fixes#818
The `paramsFile` is obsolete now that we use `execFileSync()` for our
internal implementation. Instead, we pass parameters to the child
process directly as a single commandline parameter to reduce file I/O.
Issue #782
This parameter isn't needed, we can easily rely on exit code status for this.
Eliminating the parameter reduces file IO, code complexity, and removes a busy
loop.
This also removes some legacy code related to streams.
Issue #782
This uses `child_process.execFileSync` instead of `execSync` to launch the child
process. This further reduces the attack surface, removing a possible point for
command injection in the ShellJS implementation.
This does not affect backwards compatibility for the `shell.exec` API (the
behavior is determined by the call to `child_process.exec` within
`src/exec-child.js`).
Issue #782
This PR refactors `shell.exec()` by putting its child process in a separate code
file. This also slightly cleans up dead code.
There's more potential to clean this up (e.g. exit status), but this is a good
enough start.
Issue #782
* test(exec): add tests for coverage
No logic change.
This adds one test to cover some missing lines, and adds some `istanbul ignore`
directives.
I see 100% line coverage for `src/exec.js` when running:
```sh
$ nyc --reporter=text --reporter=lcov ava --serial test/exec.js`
```
Fixes#742
* Fix lint
- Add @freitagbr to the bottom of the README
- Remove docs about shjs (it's not well supported)
- Remove docs about coffeescript (we don't do anything special for
coffeescript anyway)
- Modify the section about shelljs/global, since we strongly recommend
avoiding this now
- Rewrite the code example to use `require('shelljs')` instead of
shelljs/global
- Mention ESLint next to JSHint
- Reformat sections with long lines to be 80 columns
If an error exists, but has no error code, it defaults to 1 (a common code for
most Unix commands). Tests have been omitted since this is an edge case that is
difficult to reproduce.
Fixes#536