File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed
shared/features/thumbnail Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -36,24 +36,23 @@ if (typeof document === 'undefined') {
36
36
} = canvasModule ;
37
37
38
38
const getPath = ( filename : string ) => {
39
- return (
40
- 'file://' +
41
- path . join (
42
- __dirname ,
43
- '..' ,
44
- '..' ,
45
- '..' ,
46
- 'web' ,
47
- filename . split ( '/' ) . join ( path . sep ) ,
48
- )
49
- ) ;
39
+ const workingDir = process . cwd ( ) ;
40
+ const fullPath = path . join ( workingDir , filename . split ( '/' ) . join ( path . sep ) ) ;
41
+
42
+ if ( ! Bun . file ( fullPath ) . exists ( ) ) {
43
+ throw new Error ( `File not found: ${ fullPath } ` ) ;
44
+ } else {
45
+ console . log ( `File found: ${ fullPath } ` ) ;
46
+ }
47
+
48
+ return 'file://' + fullPath ;
50
49
} ;
51
50
52
51
const saveToImage = ( canvas : NapiRs . Canvas ) => canvas . encode ( 'png' ) ;
53
52
54
53
const useFont = ( ) => {
55
54
GlobalFonts . registerFromPath (
56
- 'file:' + getPath ( '/fonts/Lato-Regular.ttf' ) . toString ( ) ,
55
+ 'file:' + getPath ( 'assets /fonts/Lato-Regular.ttf' ) . toString ( ) ,
57
56
'Lato' ,
58
57
) ;
59
58
} ;
@@ -62,7 +61,7 @@ if (typeof document === 'undefined') {
62
61
63
62
try {
64
63
noteBlockImage = nodeLoadImage (
65
- new URL ( getPath ( 'public /img/note-block-grayscale.png' ) ) ,
64
+ new URL ( getPath ( 'assets /img/note-block-grayscale.png' ) ) ,
66
65
) ;
67
66
} catch ( error ) {
68
67
console . error ( 'Error loading image: ' , error ) ;
You can’t perform that action at this time.
0 commit comments