Extract percent function

master
Frédéric Matte 2022-12-30 13:52:05 -05:00
parent 9f2890ce32
commit c91f4a466b
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,7 @@
import chalk from 'chalk' import chalk from 'chalk'
const percentage = (dividend, divisor) => (dividend / divisor * 100).toFixed(0)
const totalreporter = () => { const totalreporter = () => {
let success = 0, fail = 0, skip = 0 let success = 0, fail = 0, skip = 0
@ -10,7 +12,7 @@ const totalreporter = () => {
msg: () => `${chalk.redBright(`Fail: ${fail}`)} msg: () => `${chalk.redBright(`Fail: ${fail}`)}
${chalk.greenBright(`Sucess: ${success}`)} ${chalk.greenBright(`Sucess: ${success}`)}
${chalk.blueBright(`Skip: ${skip}`)} ${chalk.blueBright(`Skip: ${skip}`)}
${chalk.yellowBright(`Ratio: ${(success / (success + fail) * 100).toFixed(0)}%`)}` ${chalk.yellowBright(`Ratio: ${percentage(success, success + fail)}%`)}`
} }
} }