Dangerfile exits early if build failed (#14400)
* Dangerfile exits early (without leaving an error comment) if build failed
Brian Vaughn committed
Dec 7, 2018 at 09:06 UTC
f64906fba1ccec5273e87f7ed3cdbf5a643ca44a
1 file changed
+9
-2
dangerfile.js
+9
-2
@@ -17,7 +17,7 @@
17
//
18
// You'll need a GitHub token, you can re-use this one:
19
//
20
-// e622517d9f1136ea8900 07c6373666312cdfaa69
20
+// 0a7d5c3cad9a6dbec2d9 9a5222cf49062a4c1ef7
21
//
22
// (Just remove the space)
23
//
@@ -29,9 +29,16 @@ const {markdown, danger} = require('danger');
29
const fetch = require('node-fetch');
30
31
const {generateResultsArray} = require('./scripts/rollup/stats');
32
-const {readFileSync} = require('fs');
32
+const {existsSync, readFileSync} = require('fs');
33
const {exec} = require('child_process');
34
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
+
42
const currentBuildResults = JSON.parse(
43
readFileSync('./scripts/rollup/results.json')
44
);