forked from microsoft/TypeScript-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdangerfile.ts
40 lines (31 loc) · 1.45 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
// 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"
// Blocked on PR deploys, see CI.yml
// import lighthouse from "danger-plugin-lighthouse"
// Spell check all the things
spellcheck({ settings: "artsy/peril-settings@spellcheck.json" })
const deployURL = process.env.PR_DEPLOY_URL_ROOT
if (deployURL) {
const msg = `Deployed to [a PR branch](${deployURL}) - [playground](${deployURL}/play) [tsconfig](${deployURL}/tsconfig) [old handbook](${deployURL}/docs/handbook/integrating-with-build-tools.html)`
message(msg)
}
// 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")}`)
}