-
Notifications
You must be signed in to change notification settings - Fork 49
/
dangerfile.ts
30 lines (28 loc) · 1.17 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
import { danger, warn, schedule } from 'danger'
// can't use import in JS
const spellcheck = require('danger-plugin-spellcheck').default
const JSON5 = require('json5')
const fs = require('fs')
const whitelistWords = JSON5.parse(fs.readFileSync('./.vscode/cSpell.json')).words
// let's spellcheck
schedule(
spellcheck({
ignore: whitelistWords.map(word => word.toLowerCase()),
whitelistFiles: ['docs/existingContributors.md'],
})
)
// Enforce yarn.lock updates
const packageChanged = danger.git.modified_files.includes('package.json')
const yarnLockfileChanged = danger.git.modified_files.includes('yarn.lock')
const npmLockfileChanged = danger.git.modified_files.includes('package-lock.json')
if (packageChanged && !yarnLockfileChanged) {
const message = 'Changes were made to package.json, but not to yarn.lock'
const idea = 'Perhaps you need to run `yarn install`?'
warn(`${message} - <i>${idea}</i>`)
}
// // Enforce package-lock.json
// if (packageChanged && !npmLockfileChanged) {
// const message = 'Changes were made to package.json, but not to package-lock.json'
// const idea = 'Perhaps you need to run `npm install`?'
// warn(`${message} - <i>${idea}</i>`)
// }