From 222be6529ca58898668d5efbc6020b3ab6e0f4fd Mon Sep 17 00:00:00 2001 From: butlerx Date: Sun, 22 Oct 2017 15:59:26 +0100 Subject: [PATCH] revert async code --- cli.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/cli.js b/cli.js index a710d51..2f14363 100644 --- a/cli.js +++ b/cli.js @@ -74,16 +74,22 @@ tty.on('disconnect', () => { console.log('disconnect'); }); -async function loadSSL({ sslkey, sslcert }) { - try { +function loadSSL({ sslkey, sslcert }) { + return new Promise((resolve, reject) => { + const ssl = {}; if (sslkey && sslcert) { - return { - key : await fs.readFile(path.resolve(sslkey)), - cert: await fs.readFile(path.resolve(sslcert)), - }; + fs + .readFile(path.resolve(sslkey)) + .then(key => { + ssl.key = key; + }) + .then(fs.readFile(path.resolve(sslcert))) + .then(cert => { + ssl.cert = cert; + }) + .then(resolve(ssl)) + .catch(reject); } - return {}; - } catch (err) { - throw err; - } + resolve(ssl); + }); }