File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import * as handlebars from 'handlebars'
2+
3+ export function formatDurationHumanReadableHelper ( ) : void {
4+ handlebars . registerHelper (
5+ 'formatDurationHumanReadable' ,
6+ ( durationMs : number ) => {
7+ if ( durationMs < 1 ) {
8+ return `1ms`
9+ } else if ( durationMs < 1000 ) {
10+ return `${ Math . floor ( durationMs ) } ms`
11+ } else if ( durationMs < 60000 ) {
12+ return `${ ( durationMs / 1000 ) . toFixed ( 1 ) } s`
13+ } else {
14+ const minutes = Math . floor ( durationMs / 60000 )
15+ const seconds = Math . floor ( ( durationMs % 60000 ) / 1000 )
16+ return `${ minutes } m${ seconds } s`
17+ }
18+ }
19+ )
20+ }
Original file line number Diff line number Diff line change 11import { uppercaseHelper } from './upper-case'
2+ import { formatDurationHumanReadableHelper } from './duration'
23
34export function registerAllHelpers ( ) : void {
45 uppercaseHelper ( )
6+ formatDurationHumanReadableHelper ( )
57}
Original file line number Diff line number Diff line change 2020- Created At: {{ github.pullRequest.createdAt }}
2121- Additions: {{ github.pullRequest.additions }}
2222- Deletions: {{ github.pullRequest.deletions }}
23- {{ /if }}
23+ {{ /if }}
24+
25+ Helper formatDurationHumanReadable: {{ formatDurationHumanReadable 3000 }}
You can’t perform that action at this time.
0 commit comments