Skip to content
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

grep includes the i flag #876

Merged
merged 5 commits into from Jul 23, 2018
Merged

grep includes the i flag #876

merged 5 commits into from Jul 23, 2018

Conversation

ppsleep
Copy link
Contributor

@ppsleep ppsleep commented Jul 19, 2018

grep includes the i flag to ignored upper/lower case differences

includes the i flag to ignored upper/lower case differences
Copy link
Member

@nfischer nfischer left a comment

This change looks good so far, but please also:

  1. npm run gendocs
  2. Add a simple test in test/grep.js

src/grep.js Outdated
@@ -17,7 +18,8 @@ common.register('grep', _grep, {
//@ Available options:
//@
//@ + `-v`: Invert `regex_filter` (only print non-matching lines).
//@ + `-l`: Print only filenames of matching files
//@ + `-l`: Print only filenames of matching files.
//@ + `-i`: Ignored upper/lower case differences.
Copy link
Member

@nfischer nfischer Jul 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you change this sentence to simply "Ignore case."?

Copy link
Member

@nfischer nfischer left a comment

One comment in-line, otherwise LGTM

@@ -0,0 +1 @@
Test3
Copy link
Member

@nfischer nfischer Jul 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK, but could you move these files under test/resources/grep/case1*? That should fix the other failures.

Copy link
Contributor Author

@ppsleep ppsleep Jul 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I moved it, and sorry for my thoughtless actions.

src/grep.js Outdated
@@ -48,6 +50,9 @@ function _grep(options, regex, files) {
}

var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8');
if (options.ignoreCase) {
regex = new RegExp(regex, 'i');
Copy link
Member

@nfischer nfischer Jul 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one more fix: move the ignoreCase logic out of the for-loop. The CI failure is because we're repeatedly re-assigning regex, but we should only assign to it once.

Copy link
Contributor Author

@ppsleep ppsleep Jul 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's a low-level error, i fixed it, sorry.

@codecov-io
Copy link

@codecov-io codecov-io commented Jul 21, 2018

Codecov Report

Merging #876 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #876      +/-   ##
==========================================
+ Coverage    95.8%   95.81%   +<.01%     
==========================================
  Files          34       34              
  Lines        1264     1266       +2     
==========================================
+ Hits         1211     1213       +2     
  Misses         53       53
Impacted Files Coverage Δ
src/grep.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8dae55f...32b154d. Read the comment docs.

@nfischer
Copy link
Member

@nfischer nfischer commented Jul 23, 2018

@ppsleep thanks for the great contribution!

@nfischer nfischer merged commit 4113a72 into shelljs:master Jul 23, 2018
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants