Fix issue #498 - c8 CLI doesn't work properly when executed in a sub-directory of the project #539
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.
This PR fixes the issue #498...and also change the philosophy of c8.
The fix
This PR makes c8 consider the
include
andexclude
patterns as relative to the configuration file location, if any, or the current working directory, otherwise. By applying such a change, c8 can be executed from any subdirectory of the project and will always resolve sources to include and exclude regardless of the current working directory, if a configuration file is present.The philosophy shift
c8 philosophy seems to have been heavily inspired by nyc, which means that it inherits from nyc debatable (and arguably archaic) design decisions. These decisions can be summarized this way:
Options
src
,include
,exclude
,extension
,excludeNodeModules
,allowExternal
andall
are overlapping and can be reduced to onlyinclude
andexclude
without removing any feature.This PR removes all the mentioned options except
include
andexclude
, and updates the logic so that all the removed options are organically available through theinclude
andexclude
options.Let's see how it goes.
--src
This option is overlapping with the
include
option, which is the declaration of the files that we want to be covered by the tests:--extension
This option is overlapping with the
include
option, which is the declaration of the files that we want to be covered by the tests:Or:
--allowExternal
This option is overlapping with the
include
option, which is the declaration of the files that we want to be covered by the tests:--excludeNodeModules
This option is overlapping with the
exclude
option, which is the declaration of the files that we don't want to be covered by the tests:--all
This option is overlapping with the
include
andexclude
options, would we want to not include all of them, it is possible through a combination ofinclude
andexclude
:This is obviously a breaking change.