792 Commits

Author SHA1 Message Date
reviewher
355bc754d2
Cleanup LICENSE (#966) 2020-10-26 16:46:43 -07:00
Nate Fischer
54049d49d8
chore: change supported node versions (#1011)
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
2020-10-26 16:44:47 -07:00
Zachary Snow
ba5d782fc2
Update ls with glob example. (#1006) 2020-09-02 23:31:59 -07:00
Chris Thielen
a8452b89f2 fix(mv): Fix moving files across volumes (#982)
At some point options parsing happened inside `_mv()` and `_cp()` but that is no longer the case so a parsed options object should be used instead.
2020-01-07 00:28:48 -08:00
Nate Fischer
aed6d994b5
chore: support up to node v13 (#978)
No change to logic. This just adds Travis and appveyor test support for
up to node v13. No change to the minimum supported version.
2019-11-13 22:35:03 -08:00
Jakob Krigovsky
9d0bdd6302 Update “OS X” to “macOS” (#977)
This updates documentation to refer to the new name for the Apple operating system.
2019-11-11 12:28:39 -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
Nate Fischer
12b8c4864f
fix(exec): join paths correctly (#975)
Previously, we just concatenated _tempDir() with '/' and a random
filename. Instead, we should join paths with path.join() to use the OS
path separator.

This is a speculative fix for issue #974, although this may not be
enough to actually make Windows happy.

Issue #974
2019-10-29 01:35:11 -07:00
Anna Henningsen
05374a7499 Silence potentially upcoming circular dependency warning (#973)
Node.js is currently considering printing a warning when a non-existent
property of `module.exports` is accessed while in a circular `require()`
dependency, in order to make it easier to catch issues with circular
dependencies.

In order to avoid printing these warnings for shelljs, checking for the
property’s existence rather than its truthiness suffices.

Refs: https://github.com/nodejs/node/pull/29935
2019-10-20 15:17:10 -07:00
Nate Fischer
9aef0026d4
chore: update dev deps (#971)
No change to logic.

This updates ava and nyc, to suppress npm audit error messages.

Fixes #969
2019-10-09 00:26:38 -07:00
Nate Fischer
37b42fef25
test: misc test changes (#970)
No change to production logic.

This renames test cases with duplicate names, deletes a redundant test,
and uses the public `t.title` API in favor of `t._test.title`.

This is a prerequisite for updating ava.

Issue #969
2019-10-08 22:41:16 -07:00
Wes Cossick
4e38240eda Add boolean fatal option to exec() function (#961)
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.
2019-10-01 23:43:54 -07: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
Nate Fischer
7aa8ce4ebd
docs(exec): minor wording changes on security doc (#951)
This is a follow-up to #950, to emphasize the message.
2019-06-26 09:39:24 -07:00
Nate Fischer
68c382221e
docs(exec): document security concerns (#950)
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
2019-06-26 08:10:59 -07:00
st-sloth
619d23493c docs(sed): clarify using sed with newlines (#949)
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.
2019-06-26 01:08:09 -07:00
Nate Fischer
a8e543a8d0
chore(lint): upgrade eslint (#947)
This upgrades eslint to a new version to resolve a security warning.
This fixes a couple new lint errors, and disables some lint checks.

The current version of the airbnb lint config triggers
DeprecationWarnings in the new version of eslint. These warnings will be
resolved in a follow-up.

Test: npm run lint
2019-06-20 23:34:41 -07:00
Nate Fischer
f7dbc61d41
chore(lint): alphabetize lint rules (#946)
No change to the rules, this just reorders the eslintrc file so there's
a sane way to add new rules.

Test: npm run lint
2019-06-20 22:52:47 -07:00
Jason Cooke
6d83d3509b docs: fix typo (#943) 2019-06-07 20:14:54 -07:00
Nate Fischer
9237f66c52
docs: clarify which methods return ShellStrings (#934)
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
2019-03-06 03:39:08 -08:00
Nate Fischer
a8775129f5
docs(changelog): updated by Nate Fischer [ci skip] 2019-01-05 00:57:58 -08:00
Nate Fischer
1560ffdc5f
feat(options): initial support for long options (#926)
* 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
2019-01-05 00:54:30 -08:00
Nate Fischer
5371e1629f
test(touch): add coverage for -d option (#925)
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
2019-01-04 02:02:04 -08:00
Nate Fischer
355287e2ff
chore(node): add v10 and v11 to CI (#921)
This adds support for v10 and v11, and removes a TODO.
2018-12-03 00:20:38 -08:00
Nate Fischer
5cab915f70
chore(test): no coverage by default (#920)
NYC takes forever on my local machine, and I generally prefer to look at
coverage reports on the website anyway.

This changes `npm test` to run without coverage, and changes our CI to
run `npm run test-with-coverage` instead.
2018-12-02 22:40:33 -08:00
Nate Fischer
e606706855
fix(exec): consistent error message for maxBuffer (#919)
* fix(exec): consistent error message for maxBuffer

This explicitly checks for maxBuffer errors in exec-child.js and
provides a consistent error message. This modifies the test to verify
this.

This also supports the change in Node v10, which emits this as a
RangeError instead of a regular Error.

Although the error message is now explicit, this is not part of our API,
since it's just tacked onto the end of exec's stderr.

Fixes #915

* Remove debugging log, ignore uncovered lines
2018-12-02 21:52:54 -08:00
Nate Fischer
3bb72eda8b
chore(node): drop node v4 and v5 (#917)
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
2018-12-01 20:23:46 -08:00
Nate Fischer
06450b8070
chore: script to bump supported node versions (#913)
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
2018-12-01 19:21:45 -08:00
Nate Fischer
87c1ff7d4c
chore(npm): remove lockfile (#911)
This removes our lockfile and our `ci-or-install` script. The lockfile
caused headaches, since `npm install` would modify the lockfile.

Unfortunately, `ci-or-install` (added in #896) didn't work reliably on
appveyor, so removing the lockfile seems easier. We remove the script
since it's now obsolete.

Fixes #893
2018-11-29 22:55:45 -08:00
Nate Fischer
5a6abb5505
chore: remove gitter integration (#907)
No change to logic.

This removes gitter integration with the project. I don't monitor gitter
right now, and I've never noticed the integration to be particularly
useful otherwise.

Test: N/A
2018-11-29 02:57:32 -08:00
Daniel Ruf
26d6e0e02b ci: change language to node_js and remove obsolete scripts (#910)
We can safely use `node_js` on all three supported platforms on Travis CI and remove the obsolete scripts.

See https://github.com/shelljs/shelljs/pull/908#issuecomment-442732567
2018-11-29 02:00:05 -08:00
Shubham Joshi
18d8bbf290 feat(cp): support update flag when recursing (#889)
Fixed `cp -Ru` ignoring `-u`, and added a test.

Fixes #808
2018-11-12 21:35:06 -08:00
Will Yardley
5da1dda414 fix: Exit 1 with no output if no match (#900) (#901)
When we can read all files, but none match, exit 1 and return no output. This
matches the behavior of grep more closely.

Fixes #900
2018-11-12 21:34:13 -08:00
Nate Fischer
d4d1317ce6
0.8.3 v0.8.3 2018-11-12 20:49:46 -08:00
Will Yardley
db317bf092 Add test case for sed on empty file (#904)
As discussed as an aside in #900, add test case with an empty file.
2018-11-12 20:46:10 -08:00
Nate Fischer
0d5ecb673e
docs(changelog): updated by Nate Fischer [ci skip] 2018-11-12 20:27:35 -08:00
Nate Fischer
6b3c7b1e44
refactor: don't expose tempdir in common.state (#903)
Previously, the cached `tempdir` value was stored in `common.state`.
Unlike the other `common.state` values, this isn't immediately useful to
other commands (they can just call the tempdir API). So, this moves the
cached value into `tempdir.js`.

This also adds a unit test for the caching behavior, and exposes
test-only helpers to verify this behavior.

Finally, this adds a note to `common.state` that values should generally
be considered read-only, since this can be important for customized
behavior. Although, I recognize our code base has one exception to this
rule (`echo()`), we should strive to maintain this.

Fixes #902
Test: Added a unit test.
2018-11-08 23:00:22 -08:00
Nate Fischer
4bd22e7742
chore(ci): fix codecov on travis (#897)
Apparently, travis hasn't been uploading any coverage data this whole
time. This fixes the command (copied from appveyor).
2018-11-06 01:47:25 -08:00
Nate Fischer
2b3b781bbc
fix: silent exec (#892)
Unconditionally apply `silent: true` when calling `common.error()` from
`exec()`. This is because errors are already printed to stderr, or are
intentionally silenced by `shell.config.silent`.

Based on #861 

Fixes #851
2018-10-27 13:51:36 -07:00
Nate Fischer
37acb86e89
chore(npm): add ci-or-install script (#896)
* chore(npm): add ci-or-install script

This adds a script which checks the npm version and runs either `npm ci`
or `npm install` based on support. This is primarily to work around an
issue where `npm install` modifies `package-lock.json` for newer npm
versions.

A side benefit is that `npm ci` is slightly faster than `npm install`.

Fixes #893
2018-10-27 13:48:31 -07:00
Nate Fischer
4e861db8f9
chore(appveyor): run entire test matrix (#886)
No change to logic.

This changes appveyor to run the entire test matrix, even if a failure
occurs early on. This is helpful for debugging.
2018-10-09 19:28:43 -07:00
Nate Fischer
d079515653
docs: remove gitter badge (#880)
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.
2018-10-09 19:28:20 -07:00
Peng Zhao
4113a72c16 grep includes the i flag (#876)
grep includes the i flag to ignored upper/lower case differences
2018-07-22 20:38:13 -07:00
Stanislav Termosa
8dae55ff4a Fix(which): match only executable files (#874)
On Unix, this only matches files with the exec bit set. On Windows, this only
matches files which are readable (since Windows has different rules for
execution).

Fixes #657.
2018-07-18 15:33:08 -07:00
Nate Fischer
6d66a1af98
chore: rename some tests (#871)
No change to logic.

This renames some tests to be a bit more readable.
2018-07-11 15:06:20 -07:00
Nate Fischer
131b88f992
Fix cp from readonly source (#870)
This is a redo of PR #555.

This rebases, cleans up a test, and fixes a bug (the original PR uses `fs.chown()` instead of `fs.chownSync()`).

Fixes #98
2018-07-09 22:53:58 -07:00
Nate Fischer
1dd437eb6b
fix(mocks): fix conflict between mocks and skip (#863)
This fixes a conflict between mocks.init() and
utils.skipOnWin/skipOnUnix. mocks.init() mocks out process.stderr.write,
which utils.js implicitly depends on.

Instead, preserve stderr.write in a local variable to avoid polluting
mocked stdio and to correctly output warning messages.

Fixes #862
Test: locally apply mocks.init() inside test/which.js
2018-06-28 14:15:54 -07:00
Nate Fischer
72ff790f4f
chore: bump dev dependencies and add package-lock (#864)
No change to logic.

This reduces install spam by bumping codecov to avoid depending on a
deprecated graceful-fs version, as well as adding a package-lock.json.
2018-06-28 14:15:38 -07:00
Brandon Freitag
93bbf684c6
Prevent require-ing bin/shjs (#848)
* Prevent require-ing bin/shjs

* Move require guard up, and improve function name

* Move require up and clarify comment
2018-06-27 00:02:32 -07:00
Nate Fischer
aa9d443e7b
chore: output npm version in travis (#850)
Knowing the `npm` version was a huge help to debugging issue #844. For
some reason, we output this on appveyor but not on Travis. This PR fixes
that.
2018-05-10 21:16:25 -07:00