Skip to content

Commit

Permalink
🐛 FIX: Lingo Format Await
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Apr 23, 2020
1 parent 5a2315e commit 5e433ee
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const options = { sortBy, limit, reverse, minimal, chart, log, json, bar };

(async () => {
// Init.
init(minimal || json);
await init(minimal || json);
const spinner = ora({ text: '' });
input === 'help' && (await cli.showHelp(0));
const states = input === 'states' ? true : false;
Expand Down
36 changes: 18 additions & 18 deletions utils/JsonOutput.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
class JsonOutput {
constructor(options) {
this.options = options;
this.values = [];
}
constructor(options) {
this.options = options;
this.values = [];
}

get asObject() {
return this.values.map(values => {
return values.reduce((acc, value, index) => {
acc[this.options.head[index]] = value;
return acc;
}, {});
});
}
get asObject() {
return this.values.map(values => {
return values.reduce((acc, value, index) => {
acc[this.options.head[index]] = value;
return acc;
}, {});
});
}

push(value) {
this.values.push(value);
}
push(value) {
this.values.push(value);
}

toString() {
return JSON.stringify(this.asObject);
}
toString() {
return JSON.stringify(this.asObject);
}
}

module.exports = JsonOutput;
2 changes: 1 addition & 1 deletion utils/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = meow(
${yellow(`--log`)}, ${yellow(`-g`)} Print logarithmic chart
${yellow(`--xcolor`)}, ${yellow(`-x`)} Single colored output
${yellow(`--minimal`)}, ${yellow(`-m`)} Minimalistic CLI output
${yellow(`--json`)}, ${yellow(`-j`)} Output as JSON
${yellow(`--json`)}, ${yellow(`-j`)} Output JSON only data
Examples
${green(`corona`)} ${cyan(`china`)}
Expand Down
7 changes: 6 additions & 1 deletion utils/getStates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ const handleError = require('cli-handle-error');
const orderBy = require('lodash.orderby');
const sortStateValidation = require('./sortStateValidation.js');

module.exports = async (spinner, output, states, { sortBy, limit, reverse, json }) => {
module.exports = async (
spinner,
output,
states,
{ sortBy, limit, reverse, json }
) => {
if (states) {
sortStateValidation(sortBy, spinner);
const [err, response] = await to(
Expand Down
4 changes: 2 additions & 2 deletions utils/getWorldwide.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module.exports = async (table, states, json) => {
const [err, response] = await to(
axios.get(`https://corona.lmao.ninja/v2/all`)
);
handleError(`API is down, try again later.`, err, false);
handleError(`API is down, try again later.`, err, false);

const allData = response.data;
const allData = response.data;
const format = numberFormat(json);

// Don't print coz for states we still need that data of updated data.
Expand Down
17 changes: 9 additions & 8 deletions utils/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ const { yellow, green } = require('chalk');
const boxen = require('boxen');

module.exports = async (skipWelcome = false) => {
unhandledError();
await unhandledError();
checkNode(`10`);
!skipWelcome && welcome(`corona-cli`, `by Awais.dev\n${pkgJSON.description}`, {
bgColor: `#007C91`,
color: `#FFFFFF`,
bold: true,
clear: true,
version: `v${pkgJSON.version}`
});
!skipWelcome &&
welcome(`corona-cli`, `by Awais.dev\n${pkgJSON.description}`, {
bgColor: `#007C91`,
color: `#FFFFFF`,
bold: true,
clear: true,
version: `v${pkgJSON.version}`
});

const update = await checkForUpdate(pkgJSON);
if (update) {
Expand Down
2 changes: 1 addition & 1 deletion utils/numberFormat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const commaNumber = require('comma-number');
const plain = num => num;

module.exports = json => json ? plain : commaNumber;
module.exports = json => (json ? plain : commaNumber);

0 comments on commit 5e433ee

Please sign in to comment.