File tree 2 files changed +6
-4
lines changed
2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { randomBytes } from "node:crypto" ;
2
+ import { tmpdir } from "node:os" ;
2
3
import { resolve } from "node:path" ;
3
4
4
5
function getDataDir ( ) {
5
- return resolve ( `/tmp/ keybr-tests-${ randomBytes ( 6 ) . toString ( "hex" ) } `) ;
6
+ return resolve ( tmpdir ( ) , ` keybr-tests-${ randomBytes ( 6 ) . toString ( "hex" ) } `) ;
6
7
}
7
8
8
9
function getPublicDir ( ) {
Original file line number Diff line number Diff line change 1
1
import { createHash } from "node:crypto" ;
2
2
import { mkdir , open , readFile , rename } from "node:fs/promises" ;
3
- import { dirname } from "node:path" ;
3
+ import { tmpdir } from "node:os" ;
4
+ import { dirname , join } from "node:path" ;
4
5
import ts from "typescript" ;
5
6
6
7
/**
@@ -26,14 +27,14 @@ export function isTsx(fileName) {
26
27
*/
27
28
export async function transpile ( source , fileName ) {
28
29
const options = getTranspileOptions ( fileName ) ;
29
- const slug = fileName . substring ( 1 ) . replace ( / [ . / ] / g, "_" ) ;
30
+ const slug = fileName . replace ( / [ . / \\ : ] / g, "_" ) ;
30
31
const hash = createHash ( "md5" )
31
32
. update ( fileName )
32
33
. update ( source )
33
34
. update ( JSON . stringify ( options ) )
34
35
. update ( ts . version )
35
36
. digest ( "hex" ) ;
36
- const cachedFilename = `/tmp/ tsl/ ${ slug } _${ hash } .js`;
37
+ const cachedFilename = join ( tmpdir ( ) , ` tsl` , ` ${ slug } _${ hash } .js`) ;
37
38
try {
38
39
return await readFile ( cachedFilename , "utf-8" ) ;
39
40
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments