File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 4
4
"scripts" : {
5
5
"start" : " npm run build && node ./dist/main.js" ,
6
6
"start:pr" : " npm run build && node ./dist/pr-bench.js" ,
7
- "compare" : " npm run build && node ./dist/compare.js" ,
7
+ "compare" : " node ./dist/compare.js" ,
8
8
"dev" : " tsc --watch" ,
9
9
"build" : " rm -rf ./dist && tsc"
10
10
},
Original file line number Diff line number Diff line change @@ -3,8 +3,11 @@ import { readJson } from 'fs-extra';
3
3
import {
4
4
DefaultBenchCase ,
5
5
ValidMetricsForCase ,
6
+ getCommitId ,
6
7
getCommitLink ,
7
8
getMetricsPath ,
9
+ getRepoName ,
10
+ getRepoPath ,
8
11
} from './shared' ;
9
12
10
13
const productName = process . argv [ 2 ] || 'MODERNJS_FRAMEWORK' ;
@@ -102,8 +105,18 @@ export async function compare(productName: string) {
102
105
103
106
arr . sort ( ( a , b ) => a . value . time - b . value . time ) ;
104
107
105
- const currentKey = arr [ arr . length - 1 ] . key ;
106
- const baseKey = arr [ arr . length - 2 ] . key ;
108
+ let currentKey = arr [ arr . length - 1 ] . key ;
109
+ let baseKey = arr [ arr . length - 2 ] ?. key || currentKey ;
110
+
111
+ if ( process . env . MONITOR !== '1' ) {
112
+ const repoPath = getRepoPath ( getRepoName ( productName ) ) ;
113
+ const id = await getCommitId ( repoPath ) ;
114
+ if ( id !== currentKey ) {
115
+ baseKey = currentKey ;
116
+ currentKey = id ;
117
+ }
118
+ }
119
+
107
120
const current = allMetrics [ currentKey as any ] ;
108
121
const base = allMetrics [ baseKey as any ] ;
109
122
const baseCommitLink = getCommitLink ( productName , baseKey ) ;
You can’t perform that action at this time.
0 commit comments