From 751a647a738507a6dc667b5d678a5b1d3cb5598a Mon Sep 17 00:00:00 2001 From: Hippo Date: Sun, 26 Apr 2020 21:11:15 +0530 Subject: [PATCH] Gracefully fail if Ghost admin not set This is still ungraceful, in the sense it'll fail spectacularly later, but at least it gives us the opportunity to run the new `setup` command first. Where's that command, you say? Just wait for the next commit! ;-) --- functions.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/functions.js b/functions.js index e45e174..4985f75 100644 --- a/functions.js +++ b/functions.js @@ -13,12 +13,15 @@ const config = require('./config') const MEDIUM_IMG_CDN = 'https://miro.medium.com/fit/c/' -const ghostAdmin = new GhostAdminAPI({ - url: config.ghost.url, - version: config.ghost.version, - key: config.ghost.admin_key, -}) - +try { + const ghostAdmin = new GhostAdminAPI({ + url: config.ghost.url, + version: config.ghost.version, + key: config.ghost.admin_key, + }) +} catch(err) { + console.error('Your Ghost isn\'t configured. Please run `seance setup` to fix this!') +} /** * function [fetchFromMedium] * @returns [string] status