2
2
3
3
import fs from 'fs' ;
4
4
import path from 'path' ;
5
+ import url from 'node:url' ;
5
6
import si from 'systeminformation' ;
6
7
import DB1KiB from './db_1KiB.js' ;
7
8
import DB1MiB from './db_1MiB.js' ;
8
9
10
+ const dirname = url . fileURLToPath ( new URL ( '.' , import . meta. url ) ) ;
11
+
9
12
async 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 } ) ;
11
14
await DB1KiB ( ) ;
12
15
await DB1MiB ( ) ;
13
16
const resultFilenames = await fs . promises . readdir (
14
- path . join ( __dirname , 'results' ) ,
17
+ path . join ( dirname , 'results' ) ,
15
18
) ;
16
19
const metricsFile = await fs . promises . open (
17
- path . join ( __dirname , 'results' , 'metrics.txt' ) ,
20
+ path . join ( dirname , 'results' , 'metrics.txt' ) ,
18
21
'w' ,
19
22
) ;
20
23
let concatenating = false ;
21
24
for ( const resultFilename of resultFilenames ) {
22
25
if ( / .+ _ m e t r i c s \. t x t $ / . test ( resultFilename ) ) {
23
26
const metricsData = await fs . promises . readFile (
24
- path . join ( __dirname , 'results' , resultFilename ) ,
27
+ path . join ( dirname , 'results' , resultFilename ) ,
25
28
) ;
26
29
if ( concatenating ) {
27
30
await metricsFile . write ( '\n' ) ;
@@ -37,7 +40,7 @@ async function main(): Promise<void> {
37
40
system : 'model, manufacturer' ,
38
41
} ) ;
39
42
await fs . promises . writeFile (
40
- path . join ( __dirname , 'results' , 'system.json' ) ,
43
+ path . join ( dirname , 'results' , 'system.json' ) ,
41
44
JSON . stringify ( systemData , null , 2 ) ,
42
45
) ;
43
46
}
0 commit comments