From f64906fba1ccec5273e87f7ed3cdbf5a643ca44a Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Fri, 7 Dec 2018 09:06:47 -0800 Subject: [PATCH] Dangerfile exits early if build failed (#14400) * Dangerfile exits early (without leaving an error comment) if build failed --- dangerfile.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dangerfile.js b/dangerfile.js index d1b22931de..1a8dd8c92f 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -17,7 +17,7 @@ // // You'll need a GitHub token, you can re-use this one: // -// e622517d9f1136ea8900 07c6373666312cdfaa69 +// 0a7d5c3cad9a6dbec2d9 9a5222cf49062a4c1ef7 // // (Just remove the space) // @@ -29,9 +29,16 @@ const {markdown, danger} = require('danger'); const fetch = require('node-fetch'); const {generateResultsArray} = require('./scripts/rollup/stats'); -const {readFileSync} = require('fs'); +const {existsSync, readFileSync} = require('fs'); const {exec} = require('child_process'); +if (!existsSync('./scripts/rollup/results.json')) { + // This indicates the build failed previously. + // In that case, there's nothing for the Dangerfile to do. + // Exit early to avoid leaving a redundant (and potentially confusing) PR comment. + process.exit(0); +} + const currentBuildResults = JSON.parse( readFileSync('./scripts/rollup/results.json') );