Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

One comment in-line, otherwise LGTM

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

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

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

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

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 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

@ppsleep thanks for the great contribution!

@nfischer nfischer merged commit 4113a72 into shelljs:master Jul 23, 2018
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.

3 participants