9 Commits

Author SHA1 Message Date
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
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
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
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
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
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
cb64b92439
test(cmd): add test for caret char (#1017)
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
2021-02-08 09:37:50 -08:00
Nate Fischer
a421b9e3a5
feat: add shell.cmd to replace exec (#866)
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
2019-10-29 18:35:14 -07:00