Skip to content

Commit 580eb4b

Browse files
committed
fix(cli): add old git params as alias to husky params
1 parent 126a712 commit 580eb4b

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

@commitlint/cli/src/cli.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,15 @@ function getEditValue(flags) {
228228
// This does not work properly with win32 systems, where env variable declarations
229229
// use a different syntax
230230
// See https://github.com/marionebl/commitlint/issues/103 for details
231-
// This has been superceded by the `-E HUSKY_GIT_PARAMS` / `-E HUSKY_GIT_PARAMS`
232-
if (edit === '$HUSKY_GIT_PARAMS' || edit === '%HUSKY_GIT_PARAMS%') {
231+
// This has been superceded by the `-E GIT_PARAMS` / `-E HUSKY_GIT_PARAMS`
232+
if (
233+
[
234+
'$HUSKY_GIT_PARAMS',
235+
'%HUSKY_GIT_PARAMS%',
236+
'$GIT_PARAMS',
237+
'%GIT_PARAMS%'
238+
].includes(edit)
239+
) {
233240
console.warn(`Using environment variable syntax (${edit}) in -e |\
234241
--edit is deprecated. Use '{-E|--env} HUSKY_GIT_PARAMS instead'`);
235242
if (!('HUSKY_GIT_PARAMS' in process.env)) {

@commitlint/cli/src/cli.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,24 @@ test('should work with husky commitmsg hook in sub packages', async () => {
109109
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
110110
});
111111

112+
test('should work with husky via commitlint -e $GIT_PARAMS', async () => {
113+
const cwd = await git.bootstrap('fixtures/husky/integration');
114+
await writePkg({scripts: {commitmsg: `'${bin}' -e $GIT_PARAMS`}}, {cwd});
115+
116+
await execa('npm', ['install'], {cwd});
117+
await execa('git', ['add', 'package.json'], {cwd});
118+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
119+
});
120+
121+
test('should work with husky via commitlint -e %GIT_PARAMS%', async () => {
122+
const cwd = await git.bootstrap('fixtures/husky/integration');
123+
await writePkg({scripts: {commitmsg: `'${bin}' -e %GIT_PARAMS%`}}, {cwd});
124+
125+
await execa('npm', ['install'], {cwd});
126+
await execa('git', ['add', 'package.json'], {cwd});
127+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
128+
});
129+
112130
test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async () => {
113131
const cwd = await git.bootstrap('fixtures/husky/integration');
114132
await writePkg(

0 commit comments

Comments
 (0)