From 1b2153ad8bd5700e8ba5bb361e92446c2c850161 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sat, 21 Dec 2019 16:07:52 -0500 Subject: [PATCH] Refactor init --- index.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index fc8a5c3..3e71a65 100644 --- a/index.js +++ b/index.js @@ -2,15 +2,10 @@ const wizard = require('./src/wizard'); const parser = require('./src/parser'); const writer = require('./src/writer'); -async function init() { - try { - config = wizard.getConfig(); - let posts = await parser.parseFilePromise(config) - await writer.writeFilesPromise(posts, config); - } catch (ex) { - // appease the UnhandledPromiseRejectionWarning - console.error(ex); - } -} - -init(); +(async () => { + config = wizard.getConfig(); + let posts = await parser.parseFilePromise(config) + await writer.writeFilesPromise(posts, config); +})().catch(ex => { + console.error(ex); +});