File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 8
8
*/
9
9
import fs from 'fs/promises' ;
10
10
import path from 'path' ;
11
- const { utils } = require ( '@stylexjs/shared' ) ;
11
+ import { utils } from '@stylexjs/shared' ;
12
12
13
13
const hash = utils . hash ;
14
14
@@ -17,6 +17,26 @@ export function getDefaultCachePath() {
17
17
return path . join ( 'node_modules' , '.stylex-cache' ) ;
18
18
}
19
19
20
+ function findProjectRoot ( startDir = process . cwd ( ) ) {
21
+ let currentDir = startDir ;
22
+
23
+ while ( currentDir !== path . parse ( currentDir ) . root ) {
24
+ if ( fs . existsSync ( path . join ( currentDir , 'package.json' ) ) ) {
25
+ return currentDir ;
26
+ }
27
+ currentDir = path . dirname ( currentDir ) ;
28
+ }
29
+
30
+ throw new Error ( 'Project root not found' ) ;
31
+ }
32
+
33
+ export async function getCacheFilePath ( cachePath , filePath ) {
34
+ const projectRoot = path . join ( __dirname , '../../../' ) ;
35
+ const relativePath = path . relative ( projectRoot , filePath ) ;
36
+ const fileName = relativePath . replace ( / [ \\ / ] / g, '__' ) ;
37
+ return path . join ( cachePath , `${ fileName } .json` ) ;
38
+ }
39
+
20
40
export async function getCacheFilePath ( cachePath , filePath ) {
21
41
const projectRoot = path . resolve ( ) ;
22
42
const relativePath = path . relative ( projectRoot , filePath ) ;
You can’t perform that action at this time.
0 commit comments