File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
scripts/create-lang/template Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 1
1
const path = require ( 'node:path' )
2
- const libPath = path . join ( __dirname , 'parser.so' )
2
+
3
+ function getLibPath ( ) {
4
+ const prebuild = resolvePrebuild ( __dirname )
5
+ if ( prebuild ) {
6
+ return prebuild ;
7
+ }
8
+
9
+ const native = path . join ( __dirname , 'parser.so' ) ;
10
+ if ( fs . existsSync ( native ) ) {
11
+ return native ;
12
+ }
13
+
14
+ throw new Error ( 'No parser found. Please ensure the parser is built or a prebuild is available.' ) ;
15
+ }
16
+
17
+ let libPath ;
3
18
4
19
module . exports = {
5
- libraryPath : libPath ,
20
+ get libraryPath ( ) {
21
+ if ( ! libPath ) {
22
+ libPath = getLibPath ( ) ;
23
+ }
24
+ return libPath ;
25
+ } ,
6
26
extensions : $$EXTENSIONS$$ ,
7
27
languageSymbol : 'tree_sitter_$$NAME$$' ,
8
28
expandoChar : '$$EXPANDO_CHAR$$' ,
You can’t perform that action at this time.
0 commit comments