22
33import fs from 'fs' ;
44import path from 'path' ;
5+ import url from 'node:url' ;
56import si from 'systeminformation' ;
67import DB1KiB from './db_1KiB.js' ;
78import DB1MiB from './db_1MiB.js' ;
89
10+ const dirname = url . fileURLToPath ( new URL ( '.' , import . meta. url ) ) ;
11+
912async function main ( ) : Promise < void > {
10- await fs . promises . mkdir ( path . join ( __dirname , 'results' ) , { recursive : true } ) ;
13+ await fs . promises . mkdir ( path . join ( dirname , 'results' ) , { recursive : true } ) ;
1114 await DB1KiB ( ) ;
1215 await DB1MiB ( ) ;
1316 const resultFilenames = await fs . promises . readdir (
14- path . join ( __dirname , 'results' ) ,
17+ path . join ( dirname , 'results' ) ,
1518 ) ;
1619 const metricsFile = await fs . promises . open (
17- path . join ( __dirname , 'results' , 'metrics.txt' ) ,
20+ path . join ( dirname , 'results' , 'metrics.txt' ) ,
1821 'w' ,
1922 ) ;
2023 let concatenating = false ;
2124 for ( const resultFilename of resultFilenames ) {
2225 if ( / .+ _ m e t r i c s \. t x t $ / . test ( resultFilename ) ) {
2326 const metricsData = await fs . promises . readFile (
24- path . join ( __dirname , 'results' , resultFilename ) ,
27+ path . join ( dirname , 'results' , resultFilename ) ,
2528 ) ;
2629 if ( concatenating ) {
2730 await metricsFile . write ( '\n' ) ;
@@ -37,7 +40,7 @@ async function main(): Promise<void> {
3740 system : 'model, manufacturer' ,
3841 } ) ;
3942 await fs . promises . writeFile (
40- path . join ( __dirname , 'results' , 'system.json' ) ,
43+ path . join ( dirname , 'results' , 'system.json' ) ,
4144 JSON . stringify ( systemData , null , 2 ) ,
4245 ) ;
4346}
0 commit comments