@@ -3,6 +3,7 @@ import * as cp from 'node:child_process';
3
3
import * as fs from 'node:fs' ;
4
4
import * as os from 'node:os' ;
5
5
import * as path from 'node:path' ;
6
+ import * as url from 'node:url' ;
6
7
7
8
import { localRepoPath } from './utils' ;
8
9
@@ -95,7 +96,8 @@ function prepareBenchmarkProjects(
95
96
const repoDir = path . join ( tmpDir , hash ) ;
96
97
fs . rmSync ( repoDir , { recursive : true , force : true } ) ;
97
98
fs . mkdirSync ( repoDir ) ;
98
- exec ( `git archive "${ hash } " | tar -xC "${ repoDir } "` ) ;
99
+ exec ( `git clone --quiet "${ localRepoPath ( ) } " "${ repoDir } "` ) ;
100
+ exec ( `git checkout --quiet --detach "${ hash } "` , { cwd : repoDir } ) ;
99
101
exec ( 'npm --quiet ci --ignore-scripts' , { cwd : repoDir } ) ;
100
102
fs . renameSync ( buildNPMArchive ( repoDir ) , archivePath ) ;
101
103
fs . rmSync ( repoDir , { recursive : true } ) ;
@@ -374,10 +376,13 @@ interface BenchmarkSample {
374
376
}
375
377
376
378
function sampleModule ( modulePath : string ) : BenchmarkSample {
379
+ // To support Windows we need to use URL instead of path
380
+ const moduleURL = url . pathToFileURL ( modulePath ) ;
381
+
377
382
const sampleCode = `
378
383
import fs from 'node:fs';
379
384
380
- import { benchmark } from '${ modulePath } ';
385
+ import { benchmark } from '${ moduleURL } ';
381
386
382
387
// warm up, it looks like 7 is a magic number to reliably trigger JIT
383
388
benchmark.measure();
0 commit comments