forked from microsoft/TypeScript-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dangerfile.ts
45 lines (35 loc) · 1.56 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
38
39
40
41
42
43
44
45
// This Dangerfile only runs on same-repo PRs
// You can test it by running
// yarn danger pr https://github.com/microsoft/TypeScript-Website/pull/115
import { danger, message, markdown } from 'danger'
import { basename } from 'path'
import spellcheck from 'danger-plugin-spellcheck'
import lighthouse from 'danger-plugin-lighthouse'
// Spell check all the things
spellcheck({
settings: 'artsy/[email protected]',
codeSpellCheck: ['Examples/**/*.ts', 'Examples/**/*.js'],
})
// Print out the PR url
const deployURL = `https://typescript-v2-${danger.github.pr.number}.ortam.now.sh`
message(
`Deployed to [a PR branch](${deployURL}) - [playground](${deployURL}/en/play) [tsconfig](${deployURL}/en/tsconfig) [old handbook](${deployURL}/docs/handbook/integrating-with-build-tools.html)`
)
// Look for new snapshots and show in a HTML table
const snapshots = danger.git.fileMatch('packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/*.png')
if (snapshots.modified) {
const oldSha = danger.github.pr.base.sha
const newSha = danger.github.pr.head.sha
const tables = snapshots.getKeyedPaths().modified.map(p => {
const oldURL = `https://raw.githubusercontent.com/microsoft/TypeScript-Website/${oldSha}/${p}`
const newURL = `https://raw.githubusercontent.com/microsoft/TypeScript-Website/${newSha}/${p}`
return `
###### \`${basename(p)}\`
Before | After
:-------------------------:|:-------------------------:
![](${oldURL}) | ![](${newURL})
`
})
markdown(`## Snapshots updated\n\n ${tables.join('\n\n')}`)
}
lighthouse()