No change to logic. This checks for stale README in the unit tests
instead of by calling 'gendocs' directly.
The main goal is for GitHub CI to stop getting tripped up by
package-lock.json formatting changes. `npm install` sometimes overwrites
the package-lock file with a new format, and this breaks the
after-travis step.
Test: node_modules/.bin/ava test/docs.js
This removes the shjs binary. This feature was not widely used and it
was buggy. The recommended workaround is to invoke scripts directly with
'node' (you may also need to set your NODE_PATH environmental variable).
Dropping this script lets us trim down the dependency tree.
For those who still need the original script, the source code has moved
to https://github.com/shelljs/shjs.
This is an internal refactor to change how we handle execa errors inside
of shell.cmd().
This also adds a test case for a command which fails silently to make
sure that we handle this case correctly.
Adds the -B (before context), -A (after context), and -C (before+after context) options to grep. Example usage:
```
grep -B <num> [args...]
grep -A <num> [args...]
```
This adds a dedicated if-condition to handle internal errors from execa
(timeout, maxBuffer, etc.) and to distinguish these from "regular"
errors (the command executed, but it failed with non-zero status).
This updates ava to v6. This resolves some `npm audit` warnings in our
project's devDependencies. This adds `workerThreads: false` because
operations like `process.chdir()` don't work in workers (but are
required for shelljs).
This is a partial fix#1180, although I found more errors when I ran the
tests locally on v22.10.0.
Test: npm audit
This is a followup to PR #1211 to use promises everywhere and migrate
away from `test.cb()`. The `test.cb()` function is removed in a future
version of ava.
I made an attempt to convert the skipped shell.cmd() async test cases,
but async functionality isn't implemented so it's possible the test
conversion is not totally correct.
No change to logic. This swaps out utils.runScript() to return a Promise
instead of taking a callback. This also moves some of `test.cb()` cases
over to async functions instead.
No change to logic. This adds unit tests for glob expansion.
This includes one test case for behavior which was broken by v0.9.0
(probably due to the switch to fastglob). This behavior hasn't been
fixed yet, so the test is marked as skipped.
Issue #1197
No change to logic. This swaps out Array.prototype.indexOf in favor for
Array.prototype.includes() to simplify logic. This does the same for the
equivalent String.prototype functions.
Test: npm test
No change to logic. This adds documentation for the test case for
handling newlines.
This also removes a nearby eslint suppression which is no longer
necessary after PR #1184.
Fixes#175
No change to logic. This refactors the exec-child.js script to move all
of its main logic into a main() function. This function is only invoked
if the script is executed, not when it is imported.
Importing the script is now a NOOP instead of throwing an exception.
It's still not advisable to import the script, however this can be done
if absolutely necessary to trick JavaScript bundlers which try to prune
non-imported code files.
Partially related to issue #1160 and #1172.
shell.cmd() was originally implemented in #866, however was not yet
exposed. This command should be ready for people to try out, so this
exposes the command by default.
This is still not a full implementation of everything in the
https://shelljs.page.link/cmd-design design doc, however this completes
the initial phase and is likely good enough to replace most use cases of
synchronous shell.exec().
Fixes#495
This swaps out quote characters to limit how often we need to escape
strings. This is just to improve code readability.
Almost all of the changes could be done without changes to .eslintrc,
however this amends the lint rule to also permit backtick strings which
can be useful to eliminate a few extra instances of quote escaping.
Fixes issue #788
Test: npm run lint
Dropping support for everything before node v18, which is the current
maintenance LTS and also the version in Ubuntu 24.04 LTS.
This also updates all devDependencies while trying to minimize the
required source code changes. Some devDependencies can go higher still
(ava, chalk), but this is going to require extensive refactoring.
Test: npm run test-with-coverage
Test: npm run lint
Test: npm run check-node-support
No change to logic. This updates some test cases to create the files
they need inside the temp directory instead of in the repo itself. This
is helpful in case the test case fails early, that way we don't leave
this file behind.
This contributes toward #828, since the change to fast-glob made it
clear that this test was mishandling link files and leaving side effects
in the git repo. However this change is desirably independent of
fast-glob.
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
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.
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
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 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
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
This upgrades eslint to a new version to resolve a security warning.
This fixes a couple new lint errors, and disables some lint checks.
The current version of the airbnb lint config triggers
DeprecationWarnings in the new version of eslint. These warnings will be
resolved in a follow-up.
Test: npm run lint
* feat(options): initial support for long options
This adds initial support for long options. This integration tests them
with `shell.touch()` and unit tests them in `test/common.js`. This
documents the new syntax.
This also refactors some of the common internals:
* Creates a new CommandError type to replace the `'earlyExit'` hack
* Clearer Error types for `parseOptions()` exceptions
* Removes side effects from a test which modifies `common.config`
* Fixes appveyor and travis config to run lint (regressed in #920)
Issue #924
Test: touch.js, common.js
* small refactor for errorOptions
No change to production logic.
We never had coverage for `touch({'-d': ...})`, so this adds test
coverage. This also updates documentation to clarify the parameter
should be an instance of the `Date` type.
Test: `handles date argument` case
* fix(exec): consistent error message for maxBuffer
This explicitly checks for maxBuffer errors in exec-child.js and
provides a consistent error message. This modifies the test to verify
this.
This also supports the change in Node v10, which emits this as a
RangeError instead of a regular Error.
Although the error message is now explicit, this is not part of our API,
since it's just tacked onto the end of exec's stderr.
Fixes#915
* Remove debugging log, ignore uncovered lines
Previously, the cached `tempdir` value was stored in `common.state`.
Unlike the other `common.state` values, this isn't immediately useful to
other commands (they can just call the tempdir API). So, this moves the
cached value into `tempdir.js`.
This also adds a unit test for the caching behavior, and exposes
test-only helpers to verify this behavior.
Finally, this adds a note to `common.state` that values should generally
be considered read-only, since this can be important for customized
behavior. Although, I recognize our code base has one exception to this
rule (`echo()`), we should strive to maintain this.
Fixes#902
Test: Added a unit test.
Unconditionally apply `silent: true` when calling `common.error()` from
`exec()`. This is because errors are already printed to stderr, or are
intentionally silenced by `shell.config.silent`.
Based on #861Fixes#851