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.
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. 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.
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
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.
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
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
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
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
* 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
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.
* 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