886 Commits

Author SHA1 Message Date
Nate Fischer
cd1ffdd7b5
chore: update node on GitHub actions
No change to logic. This adds Node v24 to GitHub Actions CI.
2025-11-18 21:21:54 -08:00
Nate Fischer
d44f3b95a6 chore: update deps
No change to logic. This updates dependencies using `npm audit fix`.
2025-11-18 21:11:30 -08:00
Nate Fischer
475797321a chore: update deps
No change to logic. This updates dependencies using `npm audit fix`.
2025-09-01 18:48:39 -07:00
Nate Fischer
4580c00398
0.10.0 v0.10.0 2025-05-09 12:16:36 -07:00
Nate Fischer
9a06336bc1 Deprecate the shjs binary
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.
2025-05-09 00:55:23 -07:00
Nate Fischer
3b03c85ef6
chore: remove accidental audit dep
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.
2025-05-05 16:56:51 -07:00
Nate Fischer
33db5147e2
Regenerate package-lock.json with npm 9.2.0 2025-04-29 18:11:58 -07:00
Nate Fischer
6577d5490f
Merge branch 'y-nk-main' 2025-04-29 18:10:11 -07:00
Julien Barbay
e48e919543
bump execa (#1216)
This update execa to v5.
2025-04-29 18:08:01 -07:00
Nate Fischer
67a26e2ccc refactor: change how internal errors are handled
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.
2025-04-24 19:48:23 -07:00
Alana Gilston
bfd06fa096
Add -B, -A, and -C options to grep (#1206)
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...]
```
2025-04-19 08:26:51 -07:00
Nate Fischer
3149e09d5f refactor: explicit handling for execa errors
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).
2025-04-17 13:52:12 -07:00
Nate Fischer
75d26de5b3 fix: cmd is compatible with node 22.10
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
2025-04-10 01:26:54 -07:00
Nate Fischer
8bc5833828 chore: update ava
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
2025-04-10 01:11:39 -07:00
Nate Fischer
168e8b5a08 refactor: use es6 class syntax for CommandError
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).
2025-04-10 00:56:02 -07:00
Nate Fischer
697bcf67d9 refactor: allow es6 language features
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.
2025-04-08 00:34:54 -07:00
Nate Fischer
29eba085f7 refactor: prefer promises over test.cb
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.
2025-04-07 23:52:01 -07:00
Nate Fischer
ffdd60b3b6 refactor: use expectations for t.throws
No change to logic. This is a small refactor to use stricter
"expectation" arguments for calls to t.throws().
2025-04-07 23:29:18 -07:00
Nate Fischer
dbac0a724d refactor: use promises for utils.runScript
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.
2025-04-07 22:44:41 -07:00
Nate Fischer
1a31356343 refactor: use require instead of import
No change to logic. This swaps over tests to use require() since
everything is currently designed for the commonjs module system.
2025-04-07 22:44:24 -07:00
Nate Fischer
6ce29393d7 chore: update deps 2025-04-07 21:39:11 -07:00
Alana Gilston
c836c7b6f3 Enforce single quotes 2025-04-04 20:10:06 -07:00
Nate Fischer
24ba6e24d2 refactor: avoid dependency cycle
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.
2025-03-25 21:38:04 -07:00
Nate Fischer
d43d91533e chore: rename master -> main
No change to logic. This updates the main branch name.
2025-03-23 16:16:35 -07:00
Nate Fischer
6434b5fed3 chore: update deps
This updates shelljs-release, shx, and travis-check-changes to the
latest versions.
2025-03-16 18:44:57 -07:00
Nate Fischer
b90139fb62
0.9.2 v0.9.2 2025-03-16 17:50:04 -07:00
Nate Fischer
0a47587c92 fix: add package.json to exports list
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
2025-03-08 22:55:22 -08:00
Nate Fischer
c94a3979d0 chore: remove unused env var
No change to logic. This env variable isn't relevant since we dropped
support for older node versions.
2025-03-08 18:02:12 -08:00
Nate Fischer
4fe8897b39 test: add tests for shelljs glob expansion
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
2025-03-08 17:08:14 -08:00
Nate Fischer
8c3c2ac385
0.9.1 v0.9.1 2025-03-08 15:42:37 -08:00
Nate Fischer
f08195a1fd fix: add global.js and plugin.js to exports list
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.
2025-03-08 15:39:11 -08:00
Nate Fischer
7d88393006
0.9.0 v0.9.0 2025-03-08 15:02:06 -08:00
Nate Fischer
b6f26c50cb
docs(changelog): updated by Nate Fischer
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).
2025-03-08 14:59:17 -08:00
Nate Fischer
1b3904aa8e refactor: follow up fixes for static imports
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
2025-03-08 14:46:20 -08:00
Aaron Haaf
127409cad8
Explicitly require commands (#1119)
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.
2025-03-08 14:33:52 -08:00
Nate Fischer
495933f13a chore: update ava dep
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
2025-03-08 14:18:53 -08:00
Nate Fischer
ea621f5afc chore: commit package-lock.json
No change to logic. This commits the package-lock.json file because
we've since dropped support for old Node versions.
2025-03-08 13:50:09 -08:00
Nate Fischer
ea57f4ee78 refactor: prefer includes() over indexOf()
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
2025-03-08 13:48:44 -08:00
Nate Fischer
f29a7a85af test: document test for newline in cmd() function
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
2025-02-22 00:48:06 -08:00
Nate Fischer
c3d6ce62bf chore: update maintainers list
Update list of project maintainers.
2025-02-21 15:42:53 -08:00
Nate Fischer
fca5f1b74d refactor: rewrite gendocs script without commands.js
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
2025-02-20 01:49:29 -08:00
Nate Fischer
519308489c refactor: move exec-child logic into main function
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.
2025-02-20 00:32:19 -08:00
Nate Fischer
65baedbf52 feat: expose new shell.cmd()
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
2025-02-20 00:26:35 -08:00
Nate Fischer
13cfe8a258 refactor: switch to fast-glob
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 #828
Fixes #1149
2025-02-19 23:08:27 -08:00
Nate Fischer
03d2f20e27 refactor: unescape quotes
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
2025-02-19 22:35:39 -08:00
Keith Mashinter
d9d7f4d211
Add the exit code to the fatal error thrown from common.error(). (#1179)
Merged-by: Nate Fischer <ntfschr@google.com>
2025-02-19 21:41:54 -08:00
Nate Fischer
7e71b2686d chore: drop support for old node versions
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
2025-02-17 22:31:10 -08:00
Nate Fischer
9e51217484 chore: switch to testing LTS releases only
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.
2025-02-16 11:04:39 -08:00
Nate Fischer
81ed1226d2 chore: pin node v22.9.0
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.
2025-02-16 10:20:37 -08:00
Nate Fischer
8a960da838 chore(dependencies): update js-yaml
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).
2024-06-23 12:42:52 -07:00