From 754d4087b474a811bc0614e757e9d76563a6bedf Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 7 Apr 2020 23:44:48 +0300 Subject: [PATCH] feature(cloudcmd) promise -> async --- bin/cloudcmd.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index bfc631f3..b7201064 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -20,8 +20,6 @@ const config = createConfig({ const env = require(DIR_SERVER + 'env'); const prefixer = require(DIR_SERVER + '/prefixer'); -const noop = () => {}; - const choose = (a, b) => { if (a === undefined) return b; @@ -145,7 +143,7 @@ else if (args.help) else main(); -function main() { +async function main() { if (args.repl) repl(); @@ -211,10 +209,11 @@ function main() { const distribute = require('../server/distribute'); const importConfig = promisify(distribute.import); - const caller = (fn) => fn(); - importConfig(config) - .then(args.save ? caller(config.write) : noop); + await importConfig(config); + + if (args.save) + config.write(); start(options, config); } @@ -304,17 +303,14 @@ function repl() { require(DIR_SERVER + 'repl'); } -function checkUpdate() { +async function checkUpdate() { const load = require('package-json'); - load(Info.name, 'latest') - .then(showUpdateInfo) - .catch(noop); + const {version} = await load(Info.name, 'latest'); + showUpdateInfo(version); } -function showUpdateInfo(data) { - const {version} = data; - +function showUpdateInfo(version) { if (version === Info.version) return;