Commit a533dffb authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

bigint

parent 76dddc43
import ora from 'next/dist/compiled/ora' import ora from 'next/dist/compiled/ora'
import * as Log from './output/log' import * as Log from './output/log'
import { hrtimeDurationToString } from './duration-to-string' import { hrtimeBigIntDurationToString } from './duration-to-string'
const dotsSpinner = { const dotsSpinner = {
frames: ['.', '..', '...'], frames: ['.', '..', '...'],
...@@ -13,7 +13,7 @@ export default function createSpinner( ...@@ -13,7 +13,7 @@ export default function createSpinner(
logFn: (...data: any[]) => void = console.log logFn: (...data: any[]) => void = console.log
) { ) {
let prefixText = ` ${Log.prefixes.info} ${text} ` let prefixText = ` ${Log.prefixes.info} ${text} `
const progressStart = process.hrtime() const progressStart = process.hrtime.bigint()
if (process.stdout.isTTY) { if (process.stdout.isTTY) {
let spinner = ora({ let spinner = ora({
...@@ -70,8 +70,8 @@ export default function createSpinner( ...@@ -70,8 +70,8 @@ export default function createSpinner(
return spinner return spinner
} }
spinner.stopAndPersist = () => { spinner.stopAndPersist = () => {
const progressEnd = process.hrtime(progressStart) const duration = process.hrtime.bigint() - progressStart
text = `${text} in ${hrtimeDurationToString(progressEnd)}` text = `${text} in ${hrtimeBigIntDurationToString(duration)}`
prefixText = ` ${Log.prefixes.info} ${text} ` prefixText = ` ${Log.prefixes.info} ${text} `
spinner.prefixText = prefixText spinner.prefixText = prefixText
origStopAndPersist() origStopAndPersist()
...@@ -93,9 +93,9 @@ export default function createSpinner( ...@@ -93,9 +93,9 @@ export default function createSpinner(
}, },
stop: () => spinner, stop: () => spinner,
stopAndPersist: () => { stopAndPersist: () => {
const progressEnd = process.hrtime(progressStart) const duration = process.hrtime.bigint() - progressStart
logFn( logFn(
` ${Log.prefixes.event} ${text} in ${hrtimeDurationToString(progressEnd)}` ` ${Log.prefixes.event} ${text} in ${hrtimeBigIntDurationToString(duration)}`
) )
return spinner! return spinner!
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment