Skip to content

Commit 126a712

Browse files
committed
refactor(cli): rename old husky git params to husky prefix
1 parent ca74d90 commit 126a712

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

@commitlint/cli/src/cli.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,20 @@ function getEditValue(flags) {
224224
if (typeof edit === 'boolean') {
225225
return edit;
226226
}
227-
// The recommended method to specify -e with husky was `commitlint -e $GIT_PARAMS`
227+
// The recommended method to specify -e with husky was `commitlint -e $HUSKY_GIT_PARAMS`
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 GIT_PARAMS` / `-E HUSKY_GIT_PARAMS`
232-
if (edit === '$GIT_PARAMS' || edit === '%GIT_PARAMS%') {
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%') {
233233
console.warn(`Using environment variable syntax (${edit}) in -e |\
234-
--edit is deprecated. Use '{-E|--env} GIT_PARAMS instead'`);
235-
if (!('GIT_PARAMS' in process.env)) {
234+
--edit is deprecated. Use '{-E|--env} HUSKY_GIT_PARAMS instead'`);
235+
if (!('HUSKY_GIT_PARAMS' in process.env)) {
236236
throw new Error(
237-
`Received ${edit} as value for -e | --edit, but GIT_PARAMS is not available globally.`
237+
`Received ${edit} as value for -e | --edit, but HUSKY_GIT_PARAMS is not available globally.`
238238
);
239239
}
240-
return process.env.GIT_PARAMS;
240+
return process.env.HUSKY_GIT_PARAMS;
241241
}
242242
return edit;
243243
}

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

+10-4
Original file line numberDiff line numberDiff line change
@@ -109,18 +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 () => {
112+
test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async () => {
113113
const cwd = await git.bootstrap('fixtures/husky/integration');
114-
await writePkg({scripts: {commitmsg: `'${bin}' -e $GIT_PARAMS`}}, {cwd});
114+
await writePkg(
115+
{scripts: {commitmsg: `'${bin}' -e $HUSKY_GIT_PARAMS`}},
116+
{cwd}
117+
);
115118

116119
await execa('npm', ['install'], {cwd});
117120
await execa('git', ['add', 'package.json'], {cwd});
118121
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
119122
});
120123

121-
test('should work with husky via commitlint -e %GIT_PARAMS%', async () => {
124+
test('should work with husky via commitlint -e %HUSKY_GIT_PARAMS%', async () => {
122125
const cwd = await git.bootstrap('fixtures/husky/integration');
123-
await writePkg({scripts: {commitmsg: `'${bin}' -e %GIT_PARAMS%`}}, {cwd});
126+
await writePkg(
127+
{scripts: {commitmsg: `'${bin}' -e %HUSKY_GIT_PARAMS%`}},
128+
{cwd}
129+
);
124130

125131
await execa('npm', ['install'], {cwd});
126132
await execa('git', ['add', 'package.json'], {cwd});

0 commit comments

Comments
 (0)