From b16514219b51e80c33d704bc864ea51018405788 Mon Sep 17 00:00:00 2001 From: "Jocelyn Badgley (Twipped)" Date: Wed, 25 Aug 2021 09:12:53 -0700 Subject: [PATCH] Fail gracefully when aws.json is missing. --- gulp/publish.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gulp/publish.js b/gulp/publish.js index d966687..328d723 100644 --- a/gulp/publish.js +++ b/gulp/publish.js @@ -3,7 +3,12 @@ const awspublish = require('gulp-awspublish'); const awsrouter = require('gulp-awspublish-router'); const parallelize = require('concurrent-transform'); -var credentials = require('../aws.json'); +var credentials; +try { + credentials = require('../aws.json'); +} catch (e) { + credentials = null; +} const routes = { 'p\\/.*\\.(?:jpeg|jpg|png|gif)$': { @@ -36,6 +41,10 @@ const routes = { }; module.exports = exports = function s3deploy () { + if (!credentials) { + console.error('Cannot publish without AWS credentials present.'); // eslint-disable-line + return false; + } var publisher = awspublish.create(credentials); return src('dist/**/*')