forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dangerfile.js
26 lines (21 loc) · 784 Bytes
/
dangerfile.js
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
import { fail, danger } from 'danger';
import { flatten, intersection, isEmpty, includes } from 'lodash';
const pkg = require('./package.json'); // eslint-disable-line import/newline-after-import
const prLogConfig = pkg['pr-log'];
const checkRequiredLabels = labels => {
const requiredLabels = flatten([
prLogConfig.skipLabels || [],
Object.keys(prLogConfig.validLabels || {}),
]);
if (includes(labels, 'do not merge')) {
fail('PR is marked with "do not merge" label.');
}
const foundLabels = intersection(requiredLabels, labels);
if (isEmpty(foundLabels)) {
fail(`PR is not labeled with one of: ${JSON.stringify(requiredLabels)}`);
}
};
if (prLogConfig) {
const { labels } = danger.github.issue;
checkRequiredLabels(labels.map(l => l.name));
}