fix(cli): add environment variable cli flag #343
Merged
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.
Description
Add an argument
-E | --env
to the cli which accepts the name of an environment variable to be used for the path to the commit message file.This also fixes some minor typos in the docs.
I haven't removed the
$GIT_PARAMS
handling as that should be a breaking change. However, it could be removed in a later version.Motivation and Context
Fixes #319.
In the newest/upcoming versions of Husky (1.0.0-rc.1), the environment variable husky uses is renamed to
HUSKY_GIT_PARAMS
fromGIT_PARAMS
.This means that the cross platform support for husky built into the CLI doesn't work for this and subsequent releases.
This implements the second fix suggested in https://github.com/marionebl/commitlint/issues/319#issue-318569827.
The alternative to this would to add a patch to normaliseEdit which detects HUSKY_GIT_PARAMS. However, that would be a hack which doesn't address the issue, that there is no cross-platform way to use environment variables in a command.
Usage examples
How Has This Been Tested?
I have added two new tests, one covering a success and one covering a failure case.
Please note that I cannot get all of the tests to pass on my machine, specifically the husky integration tests. However, they pass on Travis.
I believe that this is because my windows username has a space in it, which breaks something due to the combination of husky, commitlint and the temporary directory, because I cannot reproduce this issue within my documents folder.
Note: the failure message for all of them is:
Because of this I haven't ticked
All new and existing tests passed
.Types of changes
Checklist:
EDIT: In first line, I put --edit. I meant --env.