forked from jest-community/jest-editor-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdangerfile.js
24 lines (19 loc) · 911 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
import { danger, fail } from 'danger'
import * as fs from 'fs'
const pr = danger.github.pr
const modified = danger.git.modified_files
const bodyAndTitle = (pr.body + pr.title).toLowerCase()
const trivialPR = bodyAndTitle.includes('#trivial')
const codeOnly = (file ) => file.endsWith('.js')
const filesOnly = (file) => fs.existsSync(file) && fs.lstatSync(file).isFile()
// Custom subsets of known files
const modifiedAppFiles = modified.filter(p => p.includes('src/')).filter(p => filesOnly(p) && codeOnly(p))
// Rules
// When there are app-changes and it's not a PR marked as trivial, expect
// there to be CHANGELOG changes.
const changelogChanges = modified.includes('CHANGELOG.md')
if (modifiedAppFiles.length > 0 && !trivialPR && !changelogChanges) {
fail(
'**No CHANGELOG added.** If this is a small PR, or a bug-fix for an unreleased bug add `#trivial` to your PR message and re-run CI.'
)
}