@@ -30,10 +30,6 @@ function LOCAL_DIR(...paths) {
30
30
return path . join ( __dirname , '..' , ...paths ) ;
31
31
}
32
32
33
- function TEMP_DIR ( ...paths ) {
34
- return path . join ( os . tmpdir ( ) , 'graphql-js-benchmark' , ...paths ) ;
35
- }
36
-
37
33
// Build a benchmarkable environment for the given revision
38
34
// and returns path to its 'dist' directory.
39
35
function prepareRevision ( revision ) {
@@ -43,19 +39,16 @@ function prepareRevision(revision) {
43
39
return babelBuild ( LOCAL_DIR ( ) ) ;
44
40
}
45
41
46
- if ( ! fs . existsSync ( TEMP_DIR ( ) ) ) {
47
- fs . mkdirSync ( TEMP_DIR ( ) ) ;
48
- }
49
-
50
42
// Returns the complete git hash for a given git revision reference.
51
43
const hash = exec ( `git rev-parse "${ revision } "` ) ;
52
- const dir = TEMP_DIR ( hash ) ;
53
44
54
- if ( ! fs . existsSync ( dir ) ) {
55
- fs . mkdirSync ( dir ) ;
56
- exec ( `git archive "${ hash } " | tar -xC "${ dir } "` ) ;
57
- exec ( 'yarn install' , { cwd : dir } ) ;
58
- }
45
+ const dir = path . join ( os . tmpdir ( ) , 'graphql-js-benchmark' , hash ) ;
46
+ rmdirRecursive ( dir ) ;
47
+ mkdirRecursive ( dir ) ;
48
+
49
+ exec ( `git archive "${ hash } " | tar -xC "${ dir } "` ) ;
50
+ exec ( 'yarn install' , { cwd : dir } ) ;
51
+
59
52
for ( const file of findFiles ( LOCAL_DIR ( 'src' ) , '*/__tests__/*' ) ) {
60
53
const from = LOCAL_DIR ( 'src' , file ) ;
61
54
const to = path . join ( dir , 'src' , file ) ;
0 commit comments