feature(cloudcmd) promise -> async

This commit is contained in:
coderaiser 2020-04-07 23:44:48 +03:00
parent de9a26f8ff
commit 754d4087b4

View file

@ -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;