Skip to content

refactor(cli): remove old broken husky params fallback #499

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions @commitlint/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,6 @@ function getEditValue(flags) {
if (typeof edit === 'boolean') {
return edit;
}
// The recommended method to specify -e with husky was `commitlint -e $GIT_PARAMS`
// This does not work properly with win32 systems, where env variable declarations
// use a different syntax
// See https://github.com/marionebl/commitlint/issues/103 for details
// This has been superceded by the `-E GIT_PARAMS` / `-E HUSKY_GIT_PARAMS`
if (edit === '$GIT_PARAMS' || edit === '%GIT_PARAMS%') {
console.warn(`Using environment variable syntax (${edit}) in -e |\
--edit is deprecated. Use '{-E|--env} GIT_PARAMS instead'`);
if (!('GIT_PARAMS' in process.env)) {
throw new Error(
`Received ${edit} as value for -e | --edit, but GIT_PARAMS is not available globally.`
);
}
return process.env.GIT_PARAMS;
}
return edit;
}

Expand Down
18 changes: 0 additions & 18 deletions @commitlint/cli/src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,6 @@ test('should work with husky commitmsg hook in sub packages', async () => {
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});

test('should work with husky via commitlint -e $GIT_PARAMS', async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg({scripts: {commitmsg: `'${bin}' -e $GIT_PARAMS`}}, {cwd});

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

test('should work with husky via commitlint -e %GIT_PARAMS%', async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg({scripts: {commitmsg: `'${bin}' -e %GIT_PARAMS%`}}, {cwd});

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

test('should allow reading of environment variables for edit file, succeeding if valid', async t => {
const cwd = await git.bootstrap();
await sander.writeFile(cwd, 'commit-msg-file', 'foo');
Expand Down