forked from MarkBind/markbind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dangerfile.ts
37 lines (31 loc) · 1.23 KB
/
dangerfile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { danger } from 'danger';
import * as logger from '@markbind/core/src/utils/logger';
interface Couplings {
[key: string]: string[];
}
const couplings: Couplings = {
'packages/core/src/html/CustomListIconProcessor.ts': [
'docs/userGuide/syntax/lists.md',
'packages/cli/test/functional/test_site/testList.md',
],
'package.json': ['package-lock.json'],
};
const { git } = danger;
Promise.resolve().then(() => {
const allModifiedFiles = [...git.modified_files, ...git.created_files];
const messages: string[] = [];
Object.entries(couplings).forEach(([implementationFile, dependentFiles]) => {
dependentFiles.forEach((dependentFile) => {
if (allModifiedFiles.includes(implementationFile) && !allModifiedFiles.includes(dependentFile)) {
messages.push(`Changes to ${implementationFile} should include changes to ${dependentFile}`);
}
});
});
if (messages.length > 0) {
logger.warn(`Detected issues with file couplings:\n${messages.join('\n')}`);
logger.warn('Please ensure implementation changes are accompanied '
+ 'by corresponding test or documentation updates.');
} else {
logger.info('All file couplings are correctly updated.');
}
}).catch((err: Error) => logger.error(err));