-
Notifications
You must be signed in to change notification settings - Fork 739
Add -B, -A, and -C options to grep #1206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this feature. I've provided some initial feedback that you can get started on now, but I'll need to spend more time reviewing this (expect more feedback later).
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1206 +/- ##
==========================================
+ Coverage 97.37% 97.46% +0.08%
==========================================
Files 35 35
Lines 1410 1459 +49
==========================================
+ Hits 1373 1422 +49
Misses 37 37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sorry about the commit mess. I'm not sure why checks are failing on macos and ubuntu now. |
Oh, this should be a simple fix. Can you run If that doesn't fix it, then try running the tests locally and run |
Hey, that worked, thanks! Hopefully everything looks good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but with a few more suggestions.
Thanks for working on this feature!
Released in shelljs v0.10. Thanks for the contribution! |
This adds support for shelljs/shelljs#1206. This requires special parsing logic on the shx side. Test: npm test Test: ./lib/cli.js grep -A 1 'foo' ~/foobartest.txt Test: cat ~/foobartest.txt | ./lib/cli.js grep -A 1 'foo'
This adds support for shelljs/shelljs#1206. This requires special parsing logic on the shx side. Test: npm test Test: ./lib/cli.js grep -A 1 'foo' ~/foobartest.txt Test: cat ~/foobartest.txt | ./lib/cli.js grep -A 1 'foo'
This adds support for shelljs/shelljs#1206. This requires special parsing logic on the shx side. Test: npm test Test: ./lib/cli.js grep -A 1 'foo' ~/foobartest.txt Test: cat ~/foobartest.txt | ./lib/cli.js grep -A 1 'foo'
Adds the
-B
(before context) and-A
(after context) options to grep. I may have gone overboard on tests but I wanted to make sure that most feasible configurations work (combined, separate, with space, without space).Notes
globStart
to accept a function with a parameterargs
. This allows-B
and-A
to be specified separately and a function to determine where the post-regex arguments begin..editorconfig
: Single quotes in JavaScript files.eslintrc.json
:radix
option tooff
(don't require base forparseInt()
)package.json
: PrettierarrowParens
option toavoid
(don't wrap single parameters in parentheses for arrow functions)Usage
Examples