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...]
```
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.
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 changes the README to use a standard shields.io badge for GitHub
Actions. The custom badge
(https://github.com/Atrox/github-actions-badge) was cool, but the
atrox.dev link doesn't work reliably. I noticed that shields has support
for this now, so there's no reason to use a custom badge.
One notably difference is that this badge says the build is passing even
if there's a job still in progress.
No change to logic. This expands on the `touch()` command documentation
to make it more obvious how to use multiple options, long options, etc.
This also renames a variable in a test case to make the usage more
obvious.
No change to logic. This documents that we support importing via
`import shell from 'shelljs'`.
Related to issue #1071, although some more investigation is required to
understand why the other syntax doesn't work.
File permissions on Windows are weird. This adds a brief note into the
README that this is something to watch out for. As far as I'm aware, WSL
completely avoids the weirdness because it's actually Linux (and so it
follows POSIX).
No change to logic. This documents `shell.ls('-l')`'s `.toString()`
override. I noticed this feature was not documented. This string format
should not be depended on by programmatic usage, but it's useful to make
things more human readable.
This adds testing for node v14. This removes testing for node v6 and v7
because codecov breaks on these versions. This omits node v15 because
appveyor doesn't seem to support this version. The nodejs org currently
supports [10, 12, 14, 15].
This makes a couple minor edits to the check-node-support script for
consistency with shelljs/shx#186.
This bumps the shx dependency because it seems we're hitting issue #973
on node v14.
Test: npm run check-node-support
This PR introduces a new boolean fatal option for the exec() function. Like the existing silent option, this new option allows you to override the global fatal configuration parameter on a per-command basis.
No change to logic.
This adds documentation about `shell.exec()`'s inherent vulnerability to
command injection and links to a more detailed security notice.
Issue #103, #143, #495, #765, #766, #810, #842, #938, #945
Also remove example featuring line deletion as it does not work since the regex with '\n' will never match anything, because the file content is split by '\n' so there are no '\n's to match at all.
No change to logic, only docs.
In v0.7.0, we introduced ShellStrings and changed most methods to return
them. Docs weren't appropriately updated, so this PR cross-links these
methods to the ShellString docs.
This also expands on the ShellString docs themselves, since there was
room to make this clearer.
Fixes#933
* feat(options): initial support for long options
This adds initial support for long options. This integration tests them
with `shell.touch()` and unit tests them in `test/common.js`. This
documents the new syntax.
This also refactors some of the common internals:
* Creates a new CommandError type to replace the `'earlyExit'` hack
* Clearer Error types for `parseOptions()` exceptions
* Removes side effects from a test which modifies `common.config`
* Fixes appveyor and travis config to run lint (regressed in #920)
Issue #924
Test: touch.js, common.js
* small refactor for errorOptions
No change to production logic.
We never had coverage for `touch({'-d': ...})`, so this adds test
coverage. This also updates documentation to clarify the parameter
should be an instance of the `Date` type.
Test: `handles date argument` case
This drops support for node v4 and v5. Neither is currently supported by
the Node.js team, nor by the `npm` CLI team, so it's hard to justify we
continue to support it.
The new minimum supported version is v6.
Fixes#873
No change to node support, this just adds a script.
This adds a script to check that we correctly configure all supported
node versions, since we need to update quite a few spots (README.md,
package.json, travis, appveyor).
Issue #873
Test: manual
No change to logic.
We don't really use the gitter chatroom right now, so we shouldn't
direct users to chat there. It's best to have issues reported directly
on Github.
This PR removes the gitter badge from the README.
This adds the special option string `--`, which means "no options". This can be
passed if the first parameter looks like an option (starts with a `-` followed
by 1+ letters).
Fixes#778
* Added `-q` (quiet) option to `push`, `popd`, `dirs` functions.
* Added unit tests for pushd/popd quiet mode.
* Added tests for `pushd` and `popd` with quiet mode off.
* Updated docs for `pushd` and `popd` functions.
* Moved preliminary `pushd` commands for `popd` tests before disabling of silent flag.
* Add newline to output of echo (#557)
* Add newline to output of echo
* Add test
* Throw an error if the options string does not start with '-' (#615)
* Throw an error if the options string does not start with '-'
* Add test
* Change message grammar
* Add -n option to echo
* Fix null argument issue
* Add -n tests
* Add documentation
* Add -en escaped character test
* Add function to parse options for echo
* Use parseOptions to parse echo options
* Simplify control flow
* parseOptions throws now
* Allow null to be echoed
* Prevent echo stderr on unrecognized option
* Add test to check stderr of returned value
* Use consistent variable name
* Change test message, leave TODO about console output
- Add @freitagbr to the bottom of the README
- Remove docs about shjs (it's not well supported)
- Remove docs about coffeescript (we don't do anything special for
coffeescript anyway)
- Modify the section about shelljs/global, since we strongly recommend
avoiding this now
- Rewrite the code example to use `require('shelljs')` instead of
shelljs/global
- Mention ESLint next to JSHint
- Reformat sections with long lines to be 80 columns
* feat: -L (follow symlinks) option for ls
* test: ls -L option
* docs: Add ls -L option to readme
* fix: ls -L ternary operator
* Revert "test: ls -L option"
This reverts commit dbb057ac087b23aa2c1358018d3c832dd546c5f2.
* test: ls -L option
* test: Remove duplicate test