Skip to content

Commit f64906f

Browse files
authored
Dangerfile exits early if build failed (facebook#14400)
* Dangerfile exits early (without leaving an error comment) if build failed
1 parent 8df4d59 commit f64906f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

dangerfile.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//
1818
// You'll need a GitHub token, you can re-use this one:
1919
//
20-
// e622517d9f1136ea8900 07c6373666312cdfaa69
20+
// 0a7d5c3cad9a6dbec2d9 9a5222cf49062a4c1ef7
2121
//
2222
// (Just remove the space)
2323
//
@@ -29,9 +29,16 @@ const {markdown, danger} = require('danger');
2929
const fetch = require('node-fetch');
3030

3131
const {generateResultsArray} = require('./scripts/rollup/stats');
32-
const {readFileSync} = require('fs');
32+
const {existsSync, readFileSync} = require('fs');
3333
const {exec} = require('child_process');
3434

35+
if (!existsSync('./scripts/rollup/results.json')) {
36+
// This indicates the build failed previously.
37+
// In that case, there's nothing for the Dangerfile to do.
38+
// Exit early to avoid leaving a redundant (and potentially confusing) PR comment.
39+
process.exit(0);
40+
}
41+
3542
const currentBuildResults = JSON.parse(
3643
readFileSync('./scripts/rollup/results.json')
3744
);

0 commit comments

Comments
 (0)