827 Commits

Author SHA1 Message Date
Murph Murphy
85dd4729dd
test: make a test more forgiving for systems with non-standard bash and sh paths (#1144)
Made a test
more forgiving so it passes on systems that have non-standard `bash` and
`sh` binary paths.
2023-12-06 22:48:30 -08:00
Alejandro Ojeda Gutiérrez
78ed036573
Exports shell.js and make.js on package.json (#1135)
Exports shell.js and make.js on package.json so make.js can be imported as "shelljs/make" without require file extension when using ESM.
2023-11-16 21:18:40 -08:00
Andreas Deininger
626973367f
Fixing typos (#1137)
This PR fixes a few typos that I spotted in the project.
2023-11-12 21:06:23 -08:00
Andreas Deininger
b5e53ebd12
Bump GitHub workflow actions to latest versions (#1136)
This PR bumps two GitHub workflow actions to their latest versions.
2023-11-12 21:05:27 -08: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
b8b1c4224d chore: remove codecov token
It looks like 1a1a820569f0883a317944973c15cf34431dd6c2 actually broke
codecov. Codecov is currently trying to diff all PRs against the commit
before that one, which leads to flagging previously-added lines of code
as needing coverage in the current PR.

Let's try removing the token and see if codecov is happy again.

Fixes #1124
2023-11-11 17:42:46 -08:00
Nate Fischer
b704489221 chore: keep node < 16 around longer
GitHub is removing all versions < v16 from GitHub actions. I'm trying to
keep Node coverage for as long as possible.

Issue #1140
2023-11-11 17:13:11 -08:00
Nate Fischer
a987ecfab2 chore: update nyc to v15
No change to logic. This updates nyc (code coverage tool) to version 15,
which works around a breaking change that snuck into the latest Node LTS
versions.

Unfortunately, this version of nyc appears to break Node 8 and 9. We
need to work around this problem by skipping test coverage on those
versions.

Fixes #1130
2023-11-11 16:50:13 -08:00
Nate Fischer
e7ce4df63f docs: fix typo in security policy
No change to content. This fixes a missing ')' character.
2023-09-07 01:23:24 -07: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
Nate Fischer
547a739d61 chore: update CI to test against node v20
No change to logic. This updates GitHub actions CI to test on node v19
and v20.
2023-07-07 15:41:31 -07:00
Nate Fischer
1a1a820569 chore: add codecov token
This is supposed to fix codecov.

Fixes #1124
2023-07-05 18:29:23 -07:00
Nate Fischer
a3a7e7496d chore: update CI to include v18
No change to logic. This updates GitHub actions to test up through node
v18.
2022-08-09 21:49:21 -07:00
Marco Perrando
8c926df43a
Added -L to find to visit symlinked folders too. (#1080) 2022-02-24 19:18:29 -08:00
Nate Fischer
4b6b17a635 docs(touch): clarify docs for touch() command
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.
2022-02-13 17:38:11 -08:00
Nate Fischer
5f0eab152c docs(import): document es6 import command
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.
2022-02-13 17:24:12 -08:00
Nate Fischer
9a0e5f6694
Add preserve option to cp (#869)
Co-authored-by: dwi2 <dwi2@dwi2.com>
2022-01-26 22:41:40 -08:00
Nate Fischer
a329b49780 test(cp): fix cp -Ru test cases
This fixes several issues with the cp -Ru test cases:

* Originally, I noticed the touch syntax looked wrong
* After fixing that, I was trying to figure out how the test case was
  even passing before. I realized one of the assertions was wrong (it
  was asserting sourceFile contents, but should have asserted destFile
  contents)
* I realized the test should have created a nested destination
  directory; without proper nesting, the sourceFile never actually
  collided with destFile during the copy
* Lastly, I swapped touch() usage to use hardcoded timestamps for test
  consistency
2022-01-26 20:00:00 -08:00
Nate Fischer
5d25e9b25f chore: update deps
No change to logic. This updates a bunch of devDependencies.
2022-01-25 21:48:00 -08:00
Nate Fischer
624e53d6df chore: remove codecov devDependency
No change to logic. This removes the codecov package dependency because
this is provided through GitHub Actions now.
2022-01-16 20:04:15 -08:00
Andrea Canepa
42754c14ec
Added support for -n +NUM in tail.js (with sign) (#1027) 2022-01-15 13:44:54 -08:00
fhanrath
5af16d5c38
Feature/grep n (#1057) 2022-01-15 13:39:41 -08:00
JessieFrance
403a57cb9f
Feature: Expose Error Code (#1036) 2022-01-15 13:19:47 -08:00
Shubham Joshi
b473f2eab9
sed with -i option now runs silently (#959) 2022-01-15 13:09:02 -08:00
Nate Fischer
1a8e38d6f2 docs(chmod): briefly mention Windows file perms
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).
2022-01-15 12:59:19 -08:00
Nate Fischer
f45d256940 docs(ls): document the toString() override
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.
2022-01-15 12:59:05 -08:00
Nate Fischer
b4daff5fd2
chore: add SECURITY.md (#1061)
No change to code. This adds a security policy.

Issue #1058
2022-01-06 22:39:44 -08:00
Nate Fischer
003a39d652
fix(exec): lockdown file permissions (#1060)
This locks down file permissions used by the internal implementation of
`shell.exec()`.

Issue #1058
Tested manually using the documented scenarios
2022-01-06 21:14:23 -08:00
Ian
ad911973cd
Removed mentions of documentup website (#1056) 2021-12-16 23:31:18 -08:00
Nate Fischer
d0a45166fd
chore: set up GitHub Actions CI (#1055) 2021-11-29 23:34:38 -08:00
TagawaHirotaka
0ae1dd681e
Fix test command example (#1043) 2021-09-02 23:34:41 -07:00
JessieFrance
79ae14d30d
remove file extension (#1033) 2021-06-02 16:23:58 -07:00
JessieFrance
124d3349af
Added mkdir -p tests for subdirectories (#1026) 2021-03-31 17:44:20 -07:00
Roy Ivy III
71085dba65
fix(mkdir): mitigate directory creation race condition (#1019) 2021-03-08 10:12:32 -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
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