Skip to content

Commit

Permalink
Some fixes regarding cli.js
Browse files Browse the repository at this point in the history
  • Loading branch information
nihey committed Aug 11, 2019
1 parent ba272e5 commit 96fee9a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ async function main () {

if (moment(date).isSame(moment(), 'day')) {
data = await getQuote.realtime(code)

if (!moment(data.day).isSame(date, 'day')) {
const error = new Error()
error.response = { status: 404 }
throw error
}

data = {
codneg: data.code,
preult: data.price,
Expand Down Expand Up @@ -89,7 +96,9 @@ async function main () {
console.log(chalk`Variation: ${color(formatters.percentage((data.preult - data.preabe) / data.preult))}`)
console.log(chalk`Opening: ${color(data.preabe)}`)
console.log(chalk`Closing: ${color(data.preult)}`)
console.log(chalk`Average: ${color(data.premed)}`)
if (data.premed) {
console.log(chalk`Average: ${color(data.premed)}`)
}
console.log(chalk`Max: ${color(data.premax)}`)
console.log(chalk`Min: ${color(data.premin)}`)
console.log('')
Expand Down

0 comments on commit 96fee9a

Please sign in to comment.