159 Commits

Author SHA1 Message Date
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
Nate Fischer
d81c32535b deprecate config.globOptions
This deprecates support for configuring `config.globOptions`. Exposing
this variable makes it difficult to change (or upgrade) our glob
library. This discourages users from depending on this config option
going forward.

If anyone is using `config.globOptions` then it should continue to
function, however this support is not promised for the long-term.

As far as I know, this is not a commonly used option:
https://github.com/shelljs/shelljs/issues?q=globOptions currently shows
no GitHub issues of users using this option, and there was never really
a motivation for why this needed to be exposed (#400 exposed the option
just because we could, not because we should).

This is one step toward supporting Issue #828.
2024-06-14 13:07:33 -07:00
Nate Fischer
39ebb71846 test: add coverage for exit function
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
2023-11-11 18:27:54 -08:00
Nate Fischer
f7a7c75d4d fix: shell.errorCode() honors shell.exit(code)
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
2023-07-15 21:32:05 -07:00
JessieFrance
403a57cb9f
Feature: Expose Error Code (#1036) 2022-01-15 13:19:47 -08:00
Nate Fischer
57df38c6ea
chore(lint): update lint dependencies (#948)
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
2019-07-12 12:36:55 -07:00
Zearin
9035b27403 docs: fix typos and adjust markdown formatting (#825)
Miscellaneous docs/markdown changes. No change to logic.
2018-02-19 22:21:17 -08:00
Christian Zommerfelds
80d590ec05 Small clarification of verbose flag (#691)
* small clarification of verbose flag

* nfischer's documentation suggestion

* verbose flag documentation in source file
2017-03-30 20:30:30 -07:00
Nate Fischer
2d0428b1c9 Switch commands.json -> commands.js (#668)
WebPack has issues with importing JSON directly and using JavaScript
methods on it. For this reason, using the `.forEach()` method on the
imported JSON array caused a method-not-found error.

Instead, we can make this a real JavaScript array by keeping it in a
JavaScript file and exporting it as a field.

It should be noted that exporting it as `exports = [...]` does not work,
because Node won't actually interpret it as a JavaScript array (with
the required methods). So instead we can export it as
`exports.list = [...]` and access the `list` field to get the real
JavaScript array of command names.

Fixes #667
2017-02-28 01:34:51 -08:00
Nate Fischer
ac0ff873f1 refactor: add config.reset() and .resetForTesting() (#641)
Add .reset() and .resetForTesting() to shell.config and use .resetForTesting()
as a standard set-up for unit tests.
2017-01-07 22:40:38 -08:00
Nate Fischer
1548b3da00 refactor: list all commands in commands.json (#616)
* refactor: list all commands in commands.json

This also changes the order of commands in the docs, due to how I changed
the doc-generating script.

* fix lint error and alphabetize command list
2016-12-14 17:57:11 -08:00
Nate Fischer
7b9ec7fb66 refactor: allow pipeOnly commands (methods on ShellStrings) (#493) 2016-07-27 09:26:45 -07:00
Nate Fischer
8f7a7d8c57 refactor: expose plugin utils & add initial tests (#484)
* refactor: expose plugin utils & add initial tests

* fix: plugins work with Node v0.12
2016-07-26 21:32:33 -07:00
Nate Fischer
880d732611 fix: resolve a cylcic-dependency problem (#482)
If a plugin was imported before the ShellJS instance was created, the program
would crash (common.register wouldn't be instantiated yet). Now plugins can be
imported either before or after the ShellJS instance is created.
2016-07-24 17:52:28 -07:00
Nate Fischer
bd6f96db33 refactor: hook new uniq() command using new format (#478) 2016-07-23 10:56:26 -07:00
Shubham Joshi
3367e0c6c7 feat(command): new command: uniq() (#453)
* Added uniq.js, need to add tests

* Added basic tests for uniq.js

* Implemented uniq and added tests

* Generated docs for uniq

* Fixed lint error

* Added suport for -c and -d to uniq

* Generated docs

* Fixed formatting errors. Uniq now correctly returns empty string when output is specified

* Added uniq to piped methods

* Improved comment legibility

* Cleaned up the pipeline

* Added pipe test for uniq

* Converted uniq pipe test file to use linux line endings

* Fixed linting errors
2016-07-22 15:49:09 -07:00
Nate Fischer
3951a87913 refactor: commands now register themselves (#475) 2016-07-21 17:37:11 -07:00
Nate Fischer
06c3d44e5b refactor: expose pipe-ability to command configuration (#464) 2016-06-17 16:05:59 -07:00
Nate Fischer
57a9be2693 docs: comment code better to help contributors 2016-05-12 07:40:18 -07:00
Nate Fischer
60d63015cd feat(command): new command: tail() 2016-03-31 21:05:30 -07:00
Nate Fischer
a1d5f6afb6 feat(command): new command: head() 2016-03-31 21:05:30 -07:00
Nate Fischer
f6952cb781 feat(command): new command: sort() 2016-03-31 21:05:30 -07:00
Nate Fischer
a41950770f feat(glob): expose config.globOptions.
Allow users to customize the settings of `glob.sync()` (if they so-desire). This
doesn't change the default behavior.
2016-03-24 18:06:26 -07:00
Nate Fischer
e282a9be9b docs: wildcards for all commands, other docs cleanups 2016-03-20 14:03:23 -07:00
Nate Fischer
3daa0db7e5 docs: move make tool docs to the wiki 2016-03-20 01:10:19 -07:00
Nate Fischer
98fc7f48ef feat(pipe): add support for pipes between commands 2016-02-20 22:26:31 -08:00
Nate Fischer
6ebc2d3db7 refactor(shellstring): return consistent objects
- fix(string): no longer overrides string prototype
 - exec() now returns a ShellString object
2016-02-19 14:54:30 -08:00
Nate Fischer
0166658597 fix(verbose): verbose-style logging is consistent 2016-02-16 21:11:31 -08:00
Jason McLaurin
6bf7d77ecf change config.fatal to throw an exception instead of terminating the node.js process 2016-02-16 11:19:25 -06:00
Nate Fischer
3a7eb3f2ad feat(glob): glob support for (almost) all commands 2016-02-13 21:22:48 -08:00
Nate Fischer
ca045ea4c5 feat(set): add new set() command
Add new set() command as a wrapper for `config` variables. This takes the `-e`,
`-v`, `+e`, and `+v` flags.
2016-01-31 20:17:37 -08:00
Nate Fischer
267799ae96 Docs updates 2016-01-19 16:45:35 -08:00
Brett Jones
08b4212b15 add touch(1) 2016-01-11 19:47:09 -06:00
Artur Adib
fdf633003e Bump version, update README for new make args 2015-05-19 10:51:03 -04:00
Michael Schoonmaker
b715c2c240 Add ln support, including both -s and -f options. 2013-10-10 18:03:09 -07:00
Artur Adib
a81064c33f require Node >=0.8 2013-08-26 14:04:21 -04:00
Andrew Duffy
91c82e0cc6 Fixed README so that it's based off in-source documentation
Renamed appendTo() to toEnd().
2013-08-25 19:36:16 -07:00
Andrew Duffy
78e89faf28 Added appendTo() function to imitate '>>' redirect-and-append pipe. 2013-08-25 16:36:05 -07:00
Artur Adib
561b1ea99c factoring docs, sed.js fix 2013-08-25 18:09:31 -04:00
Artur Adib
14c053abb0 chmod, clean-up 2013-08-25 17:02:37 -04:00
Artur Adib
36af72194e chmod, clean-up 2013-08-25 17:02:07 -04:00
Artur Adib
e0855c3cff exec,tempdir 2013-08-25 16:48:44 -04:00
Artur Adib
5f3da49248 dirs,pushd,popd 2013-08-25 16:34:24 -04:00
Artur Adib
93eb40d912 echo 2013-08-25 16:24:33 -04:00
Artur Adib
02df7985fd which 2013-08-25 16:23:31 -04:00
Artur Adib
715c79238e grep\ 2013-08-25 16:21:02 -04:00
Artur Adib
00c7b80cfb sed 2013-08-25 16:19:39 -04:00
Artur Adib
27978b8f9a to 2013-08-25 16:18:21 -04:00
Artur Adib
305dff0df2 cat 2013-08-25 16:16:11 -04:00