File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { runBenchmark } from '@twada/benchmark-commits' ;
2
+ import { parse } from 'acorn' ;
3
+ import { readFileSync } from 'node:fs' ;
4
+ import { join , dirname } from 'node:path' ;
5
+ import { fileURLToPath , pathToFileURL } from 'node:url' ;
6
+ import assert from 'node:assert/strict' ;
7
+ const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
8
+ const targetCode = readFileSync ( join ( __dirname , 'node_modules' , 'rimraf' , 'rimraf.js' ) ) ;
9
+
10
+ const commits = [
11
+ 'v1.6.0' ,
12
+ 'master'
13
+ ] ;
14
+
15
+ runBenchmark ( commits , async ( { suite, spec, dir } ) => {
16
+ let unassertAst ;
17
+ if ( spec . git === 'v1.6.0' ) {
18
+ unassertAst = ( await import ( pathToFileURL ( `${ dir } /index.js` ) ) ) . default ;
19
+ } else if ( spec . git === 'master' ) {
20
+ unassertAst = ( await import ( pathToFileURL ( `${ dir } /src/index.mjs` ) ) ) . unassertAst ;
21
+ } else {
22
+ assert . fail ( 'cannot be here' ) ;
23
+ }
24
+ return ( ) => {
25
+ const ast = parse ( targetCode , { ecmaVersion : '2022' } ) ;
26
+ const modifiedAst = unassertAst ( ast ) ;
27
+ assert ( modifiedAst ) ;
28
+ } ;
29
+ } ) . then ( ( suite ) => {
30
+ console . log ( 'FINISHED' ) ;
31
+ } ) ;
You can’t perform that action at this time.
0 commit comments