Skip to content

Commit bf3db8a

Browse files
authored
chore: pass danger utils to danger checks (lightdash#9450)
1 parent 66f0df5 commit bf3db8a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

dangerfile.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,17 @@ export enum DangerCheckCode {
4545
* Expected type signature for danger checks - split into two types to make
4646
* it more convenient when defining a function with DangerCheck.
4747
*/
48-
export type DangerCheck = () =>
49-
| (DangerCheck | void)
50-
| Promise<DangerCheckCode | void>;
48+
interface DangerCheckArgs {
49+
fail: typeof fail;
50+
markdown: typeof markdown;
51+
danger: typeof danger;
52+
message: typeof message;
53+
warn: typeof warn;
54+
}
55+
56+
export type DangerCheck = (
57+
args: DangerCheckArgs,
58+
) => (DangerCheck | void) | Promise<DangerCheckCode | void>;
5159

5260
type DangerCheckEntry = [description: string, DangerCheck];
5361

@@ -92,7 +100,13 @@ async function runAllChecks() {
92100
const mergedChecks = [...localChecks, ...checks];
93101

94102
for (const [description, check] of mergedChecks) {
95-
const result = await check();
103+
const result = await check({
104+
danger,
105+
fail,
106+
markdown,
107+
message,
108+
warn,
109+
});
96110

97111
/**
98112
* Handle special cases for check return values; the default behavior is

0 commit comments

Comments
 (0)