File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -19,15 +19,33 @@ if (typeof document === 'undefined') {
19
19
GlobalFonts,
20
20
} = canvasModule ;
21
21
22
- const getPath = ( filename : string ) => {
22
+ const getPath = ( filename : string ) : string => {
23
23
const workingDir = process . cwd ( ) ;
24
24
25
- const fullPath = path . join (
26
- workingDir ,
27
- filename . split ( '/' ) . join ( path . sep ) ,
28
- ) ;
25
+ // Try different possible locations for the asset files
26
+ const possiblePaths = [
27
+ // When running from package directory
28
+ path . join ( workingDir , filename . split ( '/' ) . join ( path . sep ) ) ,
29
+ // When running from root directory
30
+ path . join (
31
+ workingDir ,
32
+ 'packages' ,
33
+ 'thumbnail' ,
34
+ filename . split ( '/' ) . join ( path . sep ) ,
35
+ ) ,
36
+ ] ;
37
+
38
+ // Check which path exists
39
+ const fs = require ( 'fs' ) ;
40
+
41
+ for ( const fullPath of possiblePaths ) {
42
+ if ( fs . existsSync ( fullPath ) ) {
43
+ return fullPath ;
44
+ }
45
+ }
29
46
30
- return fullPath ;
47
+ // Default to first path if none exist
48
+ return possiblePaths [ 0 ] ! ;
31
49
} ;
32
50
33
51
const saveToImage = ( canvas : NapiRs . Canvas ) => canvas . encode ( 'png' ) ;
You can’t perform that action at this time.
0 commit comments