Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
feat: add reload time
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 6, 2019
1 parent 855d657 commit 59ee59b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 7 additions & 2 deletions bin/cli/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const PrettyError = require('pretty-error')
const getTimestamp = require('time-stamp')
const logSymbols = require('log-symbols')
const cleanStack = require('clean-stack')
const timeSpan = require('time-span')
const prettyMs = require('pretty-ms')

const logUpdate = require('log-update')
const chalk = require('chalk')
Expand Down Expand Up @@ -57,17 +59,20 @@ module.exports = {
console.log(indentString(`${symbol}${prettyErr}`, OFFSET.length))
},
restart ({ filename, forcing }) {
const end = timeSpan()
const symbol = chalk.blue(logSymbols.info)
const timestamp = chalk.gray(getCurrentTimestamp())
const header = chalk.blue(forcing ? 'restart' : 'modified')
const header = chalk.blue(forcing ? 'restart' : 'reload')
const message = chalk.gray(filename || '')
const spinner = createSpinner()
const logMessage = `${OFFSET} ${symbol} ${timestamp} ${header} ${message}`

let done = false

const timer = setInterval(() => {
done ? logUpdate(`${logMessage}`) : logUpdate(`${logMessage} ${spinner.frame()}`)
done
? logUpdate(`${logMessage} ${chalk.grey(`in ${prettyMs(end())}`)}`)
: logUpdate(`${logMessage} ${spinner.frame()}`)
}, 50)

return {
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
"url": "https://github.com/Kikobeats"
},
"contributors": [
"Kiko Beats <josefrancisco.verdu@gmail.com>",
"Roman Gräf <roman.graef@gmail.com>"
{
"name": "Kiko Beats",
"email": "josefrancisco.verdu@gmail.com"
},
{
"name": "Roman Gräf",
"email": "roman.graef@gmail.com"
}
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -59,6 +65,8 @@
"meow": "~5.0.0",
"ora": "~4.0.1",
"pretty-error": "~2.1.1",
"pretty-ms": "~5.0.0",
"time-span": "~3.1.0",
"time-stamp": "~2.2.0",
"update-notifier": "~3.0.1"
},
Expand Down

0 comments on commit 59ee59b

Please sign in to comment.