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.
I think this was installed by accident when running `npm audit`. The
`audit` module is entirely unrelated and I didn't meant to add a
dependency on this.
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).
Starting in node >= 22.10.0, a commandNotFound error will have
`undefined` values for stdout/stderr, whereas in earlier versions these
values were `null`.
Fixes#1180
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 supposed to be a NOOP, although for some reason this makes a
difference in the ava@6 test framework. This should not have a
user-visible effect because CommandError is an implementation detail of
this library (it's only thrown if `options.fatal` is off, and it's
always caught inside of common.js).
This configures the eslint config to allow ES6 features. This fixes some
lint errors caught in the new config, but this mostly suppresses new
warnings.
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.
Prior to this change, there was a dependency cycle between shell.js and
common.js. This refactors code to avoid the cycle.
This was previously reported in #1133. Node.js already worked around the
issue in v20.6.1, but it's simpler if we can avoid the dependency cycle
on our end anyway.
I tested this with `npm test` and also by running my own script which
uses a shelljs plugin. This seems to work correctly in both cases.
No change to logic. shx has a dependency on shelljs/package.json so that
it can read the ShellJS version number. This is useful for shx and
probably harmless for other packages (we need to ship the package.json
file anyway), so this adds it to the exports list as an optional export.
Fixes#1195
Test: I ran `shx --version` with this copy of shelljs as the dependency
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
We intend for dependent projects to be able to import these files, so
this adds them to the explicit list of supported exports.
Fixes#1195
Test: tested this by running shelljs-plugin-open's test suite.
Manual changelog update for v0.8.4 and v0.8.5 releases. This also
removes the 'Unreleased' section since it isn't that useful in a
changelog document.
I'm manually updating because it looks like
https://github.com/skywinder/gitlab-changelog-generator is not working
at the moment (this is what shelljs-changelog depends on).
No change to logic. This is a follow up to PR #1119. This change:
* Deletes commands.js entirely and edits the 'files' section of
package.json
* Undoes some duplicate imports (ex. src/error)
* Adds an explicit import for exec-child.js as a hint for the bundler
After this change, I expect that bundlers/minifiers such as esbuild will
now correctly process shelljs.
Fixes#1160
Currently anything that includes shelljs in it's chain cannot be bundled into a singular file due to the dynamic require. By explicitly requiring everything in src, this allows singular bundles through things like esbuild.
No change to logic. This updates ava to major version 2. This is not the
latest version, however updating to version 3 is not trivial because of
some breaking changes.
This removes the commandline options from the ava invocation in favor of
moving this into the well-supported ava JSON configuration. This is
required for Windows compatibility, because otherwise Windows won't
properly expand "test/*.js" on the commandline and ava v2 won't expand
this unless it's specified in the JSON config.
Test: npm test
Test: npm run test-with-coverage
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
The gendocs script no longer depends on commands.js. This now works by
iterating over source files and parsing them directly.
Partially related to issue #1160 and #1172.
Test: npm run gendocs
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 removes `node-glob` in favor of `fast-glob`. The main motivation
for this is because `node-glob` has a security warning and I can't
update to `node-glob@9` unless we drop compatibility for node v8.
Switching to `fast-glob` seems to be fairly straightforward, although
some options need to be changed by default for bash compatibility.
Fixes#828Fixes#1149
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 official support. We will still accept patches for non-LTS
versions when it's reasonable to support them, especially for the most
recent Node release (whether that is odd-numbered or even-numbered).
This just lightens up the workload on CI because most of our users are
probably running node LTS.
There's a bug when running on node v22.10. This temporarily pins 22 to
22.9.0 to workaround the problem and keep tests passing on CI.
Mitigation for issue #1180.
This updates js-yaml to 4.1.0 and swaps out `yaml.safeLoad()` for
`yaml.load()` because the `safe*` functions are deprecated starting in
4.0.0 (the "regular" functions are considered safe).