Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

fix: should exit with an error if no files were checked #58

Merged
merged 1 commit into from
Sep 10, 2018
Merged

fix: should exit with an error if no files were checked #58

merged 1 commit into from
Sep 10, 2018

Conversation

brandonocasey
Copy link
Contributor

Proposed Changes

es-check should exit with an error if no files were checked. I would think this is either a breaking change, or that It will need to be behind an option. Personally though, I think that this should be on by default because reporting success when no files were check is not true.

@yowainwright
Copy link
Contributor

This is a good PR. I'm going to look at this again tomorrow.

Thanks, @brandonocasey!

Copy link
Contributor

@yowainwright yowainwright left a comment

Choose a reason for hiding this comment

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

Thanks, @brandonocasey!

The thoughtful check on line 118 to 121 should stay!

  • add a test (lemme know if you'd like assistance with the test).

index.js Outdated
@@ -106,27 +106,34 @@ prog
const acornOpts = { ecmaVersion: e, silent: true }
if (esmodule) { acornOpts.sourceType = 'module'}

let globbedFiles = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove line 109.

index.js Outdated
file,
}
errArray.push(errorObj)
globbedFiles = globbedFiles.concat(glob.sync(pattern, globOpts));
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove changed to lines 115 and 116.

index.js Outdated
globbedFiles = globbedFiles.concat(glob.sync(pattern, globOpts));
});

if (globbedFiles.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a keeper. 🌟

@brandonocasey
Copy link
Contributor Author

I think I made all the changes requested, but I am not totally sure. I also added two tests, and I had to change one of the existing tests which was using shell expansion, since the glob was not quoted, and actually matching something unexpected (a folder). I will add a more in depth comment to the test.

@yowainwright
Copy link
Contributor

@brandonocasey The code looks clean! I'm on board with the this being a good breaking change.

I don't completely understand this text from your comment:

...since the glob was not quoted, and actually matching something unexpected (a folder). I will add a more in depth comment to the test.

Could you provide more detail?

Thanks, again!

@brandonocasey
Copy link
Contributor Author

brandonocasey commented Sep 10, 2018

Seems like my code comment got eaten by github. So I will give it another go. Basically the test that I fixed was unexpectedly using shell expansion since exec is being used in the tests. This means the command that is actual run for that test is:
node index.js es6 test/es5-2.js tests/es5.js tests/es6-2.js tests/es6.js tests/pkg.js

instead of
node index.js es6 ./tests/*.js

Which causes an error because tests/pkg.js is a folder and won't match any files. The fix adds quotes around what would be shell expanded, so that the command is actually what we expect:

node index.js es6 "./tests/*.js"

Which means we only have one "pattern" so as long as it matches any files it will succeed.

@yowainwright yowainwright merged commit 8e8d61f into dollarshaveclub:master Sep 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants