Skip to content

Commit 84791e3

Browse files
committed
Read the diff and only print the interesting stuff
1 parent e78d621 commit 84791e3

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

dangerfile.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
const {message} = require("danger")
22
const {readFileSync, existsSync} = require("fs")
3+
const parseDiff = require("parse-diff")
34

45
const diffPath = "./TypeScript/baseline-changes.diff"
56
if (existsSync(diffPath)) {
67
const diffContents = readFileSync(diffPath, "utf8")
7-
message(diffContents)
8+
const diffedFiles = parseDiff(diffContents)
9+
10+
const uninterestingFiles = [".generated.d.ts", "globalThisBlockscopedProperties.types", "mappedTypeRecursiveInference.types"]
11+
const withoutKnownNormalFails = diffedFiles.filter(diff => {
12+
return uninterestingFiles.filter(suffix => diff.to?.endsWith(suffix)).length > 0
13+
})
14+
15+
const md = ["## Changed baselines from the TypeScript test suite"]
16+
17+
withoutKnownNormalFails.forEach(diff => {
18+
md.push(`#### ${diff.to || diff.from}}`)
19+
20+
md.push("```diff")
21+
diff.chunks.forEach(chunk => {
22+
md.push(chunk.content)
23+
})
24+
md.push("```")
25+
})
26+
27+
28+
message(md.join("\n"))
829
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"danger": "^10.5.4",
2020
"jsdom": "^16.4.0",
2121
"node-fetch": "^2.6.1",
22+
"parse-diff": "^0.7.0",
2223
"print-diff": "^1.0.0",
2324
"styleless-innertext": "^1.1.2",
2425
"typescript": "4.1.0-dev.20200908",

0 commit comments

Comments
 (0)