This adds test coverage for the shell.exit() function. This also
refactors how we mock stdout/stderr and adds support for mocking
process.exit() (which was needed for this change).
While I was writing these tests, I realized there was an edge case I
missed in PR #1122. This change fixes that edge case.
Issue #1013
It looks like 1a1a820569f0883a317944973c15cf34431dd6c2 actually broke
codecov. Codecov is currently trying to diff all PRs against the commit
before that one, which leads to flagging previously-added lines of code
as needing coverage in the current PR.
Let's try removing the token and see if codecov is happy again.
Fixes#1124
No change to logic. This updates nyc (code coverage tool) to version 15,
which works around a breaking change that snuck into the latest Node LTS
versions.
Unfortunately, this version of nyc appears to break Node 8 and 9. We
need to work around this problem by skipping test coverage on those
versions.
Fixes#1130
This changes shell.exit() to use a wrapper function. This is so that
shell.errorCode() will have the correct error code after invoking
shell.exit(code). This isn't normally relevant, however a caller may be
listening for the exit status:
```
process.on('exit', code => {
shell.exit(shell.errorCode());
});
```
Issue #1013
No change to logic. This expands on the `touch()` command documentation
to make it more obvious how to use multiple options, long options, etc.
This also renames a variable in a test case to make the usage more
obvious.
No change to logic. This documents that we support importing via
`import shell from 'shelljs'`.
Related to issue #1071, although some more investigation is required to
understand why the other syntax doesn't work.
This fixes several issues with the cp -Ru test cases:
* Originally, I noticed the touch syntax looked wrong
* After fixing that, I was trying to figure out how the test case was
even passing before. I realized one of the assertions was wrong (it
was asserting sourceFile contents, but should have asserted destFile
contents)
* I realized the test should have created a nested destination
directory; without proper nesting, the sourceFile never actually
collided with destFile during the copy
* Lastly, I swapped touch() usage to use hardcoded timestamps for test
consistency
File permissions on Windows are weird. This adds a brief note into the
README that this is something to watch out for. As far as I'm aware, WSL
completely avoids the weirdness because it's actually Linux (and so it
follows POSIX).
No change to logic. This documents `shell.ls('-l')`'s `.toString()`
override. I noticed this feature was not documented. This string format
should not be depended on by programmatic usage, but it's useful to make
things more human readable.
No change to logic. This adds a test case to make sure the caret
character ('^') is passed through to the command. This is to make sure
the character is not treated specially on Windows, where it's an escape
character in the shell.
Fixes#1015
This adds testing for node v14. This removes testing for node v6 and v7
because codecov breaks on these versions. This omits node v15 because
appveyor doesn't seem to support this version. The nodejs org currently
supports [10, 12, 14, 15].
This makes a couple minor edits to the check-node-support script for
consistency with shelljs/shx#186.
This bumps the shx dependency because it seems we're hitting issue #973
on node v14.
Test: npm run check-node-support
This adds an initial implementation of shell.cmd(), which is intended as
the eventual replacement for shell.exec(). This PR does not fully
implement the API, but demonstrates a simple and secure alternative, and
will allow further iteration to cover other use cases in follow-up PRs.
Design doc: https://shelljs.page.link/cmd-design
Issue #495
Test: automated test suite
Previously, we just concatenated _tempDir() with '/' and a random
filename. Instead, we should join paths with path.join() to use the OS
path separator.
This is a speculative fix for issue #974, although this may not be
enough to actually make Windows happy.
Issue #974
Node.js is currently considering printing a warning when a non-existent
property of `module.exports` is accessed while in a circular `require()`
dependency, in order to make it easier to catch issues with circular
dependencies.
In order to avoid printing these warnings for shelljs, checking for the
property’s existence rather than its truthiness suffices.
Refs: https://github.com/nodejs/node/pull/29935
No change to production logic.
This renames test cases with duplicate names, deletes a redundant test,
and uses the public `t.title` API in favor of `t._test.title`.
This is a prerequisite for updating ava.
Issue #969
This PR introduces a new boolean fatal option for the exec() function. Like the existing silent option, this new option allows you to override the global fatal configuration parameter on a per-command basis.
This updates `eslint-config-airbnb-base` and `eslint-plugin-import`.
This also addresses lint errors these updates raise, and excludes
several rules.
This also adds a minor simplification to the gendocs script.
Test: npm run lint
Test: npm run gendocs
No change to logic.
This adds documentation about `shell.exec()`'s inherent vulnerability to
command injection and links to a more detailed security notice.
Issue #103, #143, #495, #765, #766, #810, #842, #938, #945