Skip to content

Commit

Permalink
fix(prompt): prompt does not respect [body-leading-blank] setting
Browse files Browse the repository at this point in the history
  • Loading branch information
weixinwu committed May 6, 2024
1 parent 756e6d6 commit 88cb735
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions @commitlint/prompt/src/inquirer/InputCustomPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default class InputCustomPrompt<

onEnd(state: SuccessfulPromptStateData): void {
this.lineSubscription.unsubscribe();
// Add or remove leading blank if rule is active.
state.value = this.opt.forceLeadingBlankFn(state.value);
super.onEnd(state);
}

Expand Down
1 change: 1 addition & 0 deletions @commitlint/prompt/src/inquirer/inquirer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare module 'inquirer' {
log?(answers?: T): string;
tabCompletion?: InputCustomCompletionOption[];
maxLength(answers?: T): number;
forceLeadingBlankFn(input: string): string;
}

interface QuestionMap<T extends Answers = Answers> {
Expand Down
1 change: 1 addition & 0 deletions @commitlint/prompt/src/library/get-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ export default function getPrompt(
transformer(value: string) {
return forceCaseFn(value);
},
forceLeadingBlankFn,
};
}

0 comments on commit 88cb735

Please sign in to comment.