Skip to content

Commit 35ffdf5

Browse files
committed
Better time output
1 parent af95b7d commit 35ffdf5

2 files changed

Lines changed: 4 additions & 22 deletions

File tree

build/lib/task.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@ function _isPromise(p) {
1313
return false;
1414
}
1515
function _renderTime(time) {
16-
if (time < 1000) {
17-
return `${time.toFixed(2)} ms`;
18-
}
19-
let seconds = time / 1000;
20-
if (seconds < 60) {
21-
return `${seconds.toFixed(1)} s`;
22-
}
23-
let minutes = Math.floor(seconds / 60);
24-
seconds -= minutes * 60;
25-
return `${minutes} m and ${seconds} s`;
16+
return `${Math.round(time)} ms`;
2617
}
2718
async function _execute(task) {
2819
const name = task.taskName || task.displayName || `<anonymous>`;
@@ -34,7 +25,7 @@ async function _execute(task) {
3425
const elapsedArr = process.hrtime(startTime);
3526
const elapsedNanoseconds = (elapsedArr[0] * 1e9 + elapsedArr[1]);
3627
if (!task._tasks) {
37-
fancyLog(`Finished`, ansiColors.cyan(name), 'after', ansiColors.green(_renderTime(elapsedNanoseconds / 1e6)));
28+
fancyLog(`Finished`, ansiColors.cyan(name), 'after', ansiColors.magenta(_renderTime(elapsedNanoseconds / 1e6)));
3829
}
3930
}
4031
async function _doExecute(task) {

build/lib/task.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,7 @@ function _isPromise(p: Promise<void> | NodeJS.ReadWriteStream): p is Promise<voi
3333
}
3434

3535
function _renderTime(time: number): string {
36-
if (time < 1000) {
37-
return `${time.toFixed(2)} ms`;
38-
}
39-
let seconds = time / 1000;
40-
if (seconds < 60) {
41-
return `${seconds.toFixed(1)} s`;
42-
}
43-
let minutes = Math.floor(seconds / 60);
44-
seconds -= minutes * 60;
45-
return `${minutes} m and ${seconds} s`;
36+
return `${Math.round(time)} ms`;
4637
}
4738

4839
async function _execute(task: Task): Promise<void> {
@@ -55,7 +46,7 @@ async function _execute(task: Task): Promise<void> {
5546
const elapsedArr = process.hrtime(startTime);
5647
const elapsedNanoseconds = (elapsedArr[0] * 1e9 + elapsedArr[1]);
5748
if (!task._tasks) {
58-
fancyLog(`Finished`, ansiColors.cyan(name), 'after', ansiColors.green(_renderTime(elapsedNanoseconds / 1e6)));
49+
fancyLog(`Finished`, ansiColors.cyan(name), 'after', ansiColors.magenta(_renderTime(elapsedNanoseconds / 1e6)));
5950
}
6051
}
6152

0 commit comments

Comments
 (0)