From 39433ebc937d89e8464b86ed38f31e70ca84fb34 Mon Sep 17 00:00:00 2001 From: tycrek Date: Mon, 5 Jul 2021 16:48:03 -0600 Subject: [PATCH] fixed setup breaking when running with no existing config --- setup.js | 5 ++++- utils.js | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/setup.js b/setup.js index 81bf006..c0c50d8 100755 --- a/setup.js +++ b/setup.js @@ -25,10 +25,13 @@ if (require.main === module) { const fs = require('fs-extra'); const prompt = require('prompt'); + // Override default config with existing config to allow migrating configs try { const existingConfig = require('./config.json'); Object.keys(existingConfig).forEach((key) => Object.prototype.hasOwnProperty.call(config, key) && (config[key] = existingConfig[key])) - } catch (ex) { console.log(ex) } + } catch (ex) { + if (ex.code !== 'MODULE_NOT_FOUND') console.log(ex); + } // Disabled the annoying "prompt: " prefix and removes colours prompt.message = ''; diff --git a/utils.js b/utils.js index b234fac..ac3a369 100755 --- a/utils.js +++ b/utils.js @@ -7,9 +7,15 @@ const token = require('./generators/token'); const zwsGen = require('./generators/zws'); const randomGen = require('./generators/random'); const gfyGen = require('./generators/gfycat'); -const { useSsl, port, domain, isProxied, diskFilePath, saveWithDate, s3bucket, s3endpoint } = require('./config.json'); const { HTTP, HTTPS, KILOBYTES } = require('./MagicNumbers.json'); +// Catch config.json not existing when running setup script +try { + var { useSsl, port, domain, isProxied, diskFilePath, saveWithDate, s3bucket, s3endpoint } = require('./config.json'); +} catch (ex) { + if (ex.code !== 'MODULE_NOT_FOUND') console.log(ex); +} + const path = (...paths) => Path.join(__dirname, ...paths); function getTrueHttp() {