-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
feat: add include
and exclude
options to instrument command
#1007
Merged
coreyfarrell
merged 17 commits into
istanbuljs:master
from
AndrewFinlay:instrument-include-exclude-option
Apr 4, 2019
Merged
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d576e44
Added `include` and `exclude` options for instrument command
39db2cc
Merge branch 'master' into instrument-include-exclude-option
880ccde
Merge branch 'master' into instrument-include-exclude-option
5f76838
Merge branch 'master' into instrument-include-exclude-option
5174d12
`nyc instrument` copies all files to an output directory, then adds i…
bd25a38
Use `var cov_` rather than `_cov` in tests
02bc210
nyc instrument now copies all files, with permissions, from `input` t…
b2eb670
Update tests, prevent in place instrumentation and instrumentation ou…
995aa1a
Include missing test files
5a28941
Ignore file permissions test if running on Windows
d22c585
Use process.platform instead of os.platform
fd69f9a
Merge branch 'master' into instrument-include-exclude-option
1fbc204
Clean up copy remaining files for nyc instrument command
e1a1b94
Make sure we can instrument the root directory
17e4736
Merge in master, update test title
6852bbf
Merge branch 'master' into instrument-include-exclude-option
8903365
Split PR such that this only handles `nyc instrument --include --excl…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This results in no output for files that are not instrumented. But if I have:
With
src/no-coverage.js
excluded, I think I still need bothdest/index.js
anddest/no-coverage.js
to be created, justdest/no-coverage.js
should be unmodified. Same if I runnyc instrument src/no-coverage.js
- that should print the original source.So I'm thinking:
I suspect this will change some of the tests, you will have to look for
cov_
or not in the output files for example instead of checking if the file exists/doesn't.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.
If I understand correctly, you're thinking your point is that
dest/
should have a fully functional codebase, just some files will be instrumented and some won't. I agree, it would be a bit shocking to be missing files, it makes it impossible to import the library.I believe we check for the
cov__
global in a few other tests, I'd look for an existing test using this approach.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.
Yes, though this idea might require bypassing
walkAllFiles
entirely, just using:Specifically
walkAllFiles
uses the extension and exclude filters which we don't really want if we're attempting to copy everything from src to dest. This could be problematic though when usingnpx nyc instrument . dest
as that would includenode_modules
. Maybenyc instrument
needs a--full-copy
option? If enabled we directly useglob.sync
to capture all files, if not then we usetestExclude.globSync
. I'm leaning towards leaving that option disabled by default.Possibly future enhancement: when
nyc instrument
copies files which havechmod +x
enabled should we do the same for the copied file?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.
Let's create an issue for keeping the perms the same; I think it would potentially even be worth splitting this into its own library -- it sounds like we want something like
cpr
that:include
/exclude
rules.Definitely beyond the scope of this pull however; although I think maintaining the existing behavior of copying over the whole directory is smart.
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.
I've pushed a new commit that addresses some of these concerns, namely copying all existing files in
input
to output before instrumentation and replacing output files in place. To do this I've brought infs-extra
as it seems like a popular and maintained module, but I'm not particularly attached to it so if it needs to change let me know of your preferred replacement.