2021-01-13 14:58:20 +03:00
const { markdown } = require ( "danger" )
2020-12-16 18:31:29 +03:00
const { readFileSync , existsSync } = require ( "fs" )
2020-12-16 19:14:46 +03:00
const parseDiff = require ( "parse-diff" )
2020-12-16 18:31:29 +03:00
2020-12-16 18:47:38 +03:00
const diffPath = "./TypeScript/baseline-changes.diff"
2020-12-16 18:31:29 +03:00
if ( existsSync ( diffPath ) ) {
const diffContents = readFileSync ( diffPath , "utf8" )
2020-12-16 19:14:46 +03:00
const diffedFiles = parseDiff ( diffContents )
const uninterestingFiles = [ ".generated.d.ts" , "globalThisBlockscopedProperties.types" , "mappedTypeRecursiveInference.types" ]
const withoutKnownNormalFails = diffedFiles . filter ( diff => {
2020-12-16 19:51:12 +03:00
return ! uninterestingFiles . filter ( suffix => diff . to && diff . to . endsWith ( suffix ) ) . length > 0
2020-12-16 19:14:46 +03:00
} )
2020-12-16 20:26:08 +03:00
const md = [ "## Changed baselines from the TypeScript test suite" , "\nThese are the test changes in the TypeScript codebase which showed a difference (excluding a few which will always change), it should give a small sense of what to expect on the TypeScript side if this PR is merged." ]
2020-12-16 19:14:46 +03:00
withoutKnownNormalFails . forEach ( diff => {
2020-12-16 20:26:08 +03:00
md . push ( ` #### [ ${ diff . to || diff . from } ](https://github.com/microsoft/TypeScript/blob/master/ ${ diff . to || diff . from } ) ` )
2020-12-16 19:51:12 +03:00
2020-12-16 19:14:46 +03:00
md . push ( "```diff" )
diff . chunks . forEach ( chunk => {
md . push ( chunk . content )
2020-12-16 19:51:12 +03:00
chunk . changes . forEach ( change => {
md . push ( change . content )
} )
2020-12-16 19:14:46 +03:00
} )
md . push ( "```" )
} )
2021-01-13 14:58:20 +03:00
if ( md . length > 2 ) {
markdown ( md . join ( "\n" ) )
}
2020-12-16 18:31:29 +03:00
}