Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #1021
- Loading branch information
Showing
10 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@pnpm/core-loggers": minor | ||
"@pnpm/default-reporter": minor | ||
"pnpm": patch | ||
--- | ||
|
||
Show execution time on `install`, `update`, `add`, and `remove` [#1021](https://github.com/pnpm/pnpm/issues/1021). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import baseLogger, { | ||
LogBase, | ||
} from '@pnpm/logger' | ||
|
||
export const finishTimeLogger = baseLogger('finish-time') | ||
|
||
export interface FinishTimeMessage { | ||
startedAt: number | ||
finishedAt: number | ||
} | ||
|
||
export type FinishTimeLog = { name: 'pnpm:finish-time' } & LogBase & FinishTimeMessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/default-reporter/src/reporterForClient/reportFinishTime.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import prettyMs from 'pretty-ms' | ||
import { FinishTimeLog } from '@pnpm/core-loggers' | ||
import * as Rx from 'rxjs' | ||
import { map, take } from 'rxjs/operators' | ||
|
||
export default ( | ||
finishTime$: Rx.Observable<FinishTimeLog> | ||
) => { | ||
return finishTime$.pipe( | ||
take(1), | ||
map((log) => { | ||
return Rx.of({ | ||
msg: `Done in ${prettyMs(log.finishedAt - log.startedAt)}`, | ||
}) | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { finishTimeLogger } from '@pnpm/core-loggers' | ||
import { toOutput$ } from '@pnpm/default-reporter' | ||
import { createStreamParser } from '@pnpm/logger' | ||
import { take } from 'rxjs/operators' | ||
|
||
test('does not print finish time for help command', (done) => { | ||
const output$ = toOutput$({ | ||
context: { | ||
argv: ['help'], | ||
}, | ||
streamParser: createStreamParser(), | ||
}) | ||
|
||
finishTimeLogger.debug({ | ||
startedAt: 1665279402859, | ||
finishedAt: 1665279413671, | ||
}) | ||
|
||
const subscription = output$.subscribe({ | ||
complete: () => done(), | ||
error: done, | ||
next: () => { | ||
done('should not log anything') | ||
}, | ||
}) | ||
|
||
setTimeout(() => { | ||
done() | ||
subscription.unsubscribe() | ||
}, 10) | ||
}) | ||
|
||
test('prints finish time for install command', (done) => { | ||
const output$ = toOutput$({ | ||
context: { | ||
argv: ['install'], | ||
}, | ||
streamParser: createStreamParser(), | ||
}) | ||
|
||
finishTimeLogger.debug({ | ||
startedAt: 1665279402859, | ||
finishedAt: 1665279413671, | ||
}) | ||
|
||
expect.assertions(1) | ||
|
||
output$.pipe(take(1)).subscribe({ | ||
complete: () => done(), | ||
error: done, | ||
next: output => { | ||
expect(output).toBe('Done in 10.8s') | ||
}, | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters