File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const assert = require('node:assert')
5
5
setup ( {
6
6
dirname : __dirname ,
7
7
name : 'toml' ,
8
+ treeSitterPackage : '@tree-sitter-grammars/tree-sitter-toml' ,
8
9
languageRegistration : toml ,
9
10
testRunner : ( parse ) => {
10
11
const sg = parse ( 'name = "Tom"' )
Original file line number Diff line number Diff line change 1
1
const { postinstall } = require ( '@ast-grep/setup-lang' )
2
2
postinstall ( {
3
- directory : __dirname ,
3
+ dirname : __dirname ,
4
4
treeSitterPackage : '@tree-sitter-grammars/tree-sitter-toml' ,
5
5
} )
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ function log(...args: unknown[]) {
11
11
12
12
interface SetupConfig {
13
13
/** Directory of the lang package. e.g. __dirname */
14
- directory : string
14
+ dirname : string
15
15
/** Package name of tree-sitter package. e.g. tree-sitter-css */
16
16
treeSitterPackage : string
17
17
}
@@ -20,7 +20,7 @@ interface SetupConfig {
20
20
* Move prebuild or build parser
21
21
*/
22
22
function postinstall ( config : SetupConfig ) {
23
- const dir = config . directory
23
+ const dir = config . dirname
24
24
const parser = path . join ( dir , 'parser.so' )
25
25
if ( fs . existsSync ( parser ) ) {
26
26
log ( 'parser already exists, skipping build' )
@@ -41,8 +41,8 @@ function postinstall(config: SetupConfig) {
41
41
}
42
42
43
43
function buildSrc ( config : SetupConfig ) {
44
- const { directory , treeSitterPackage } = config
45
- const existing = path . join ( directory , 'src' )
44
+ const { dirname } = config
45
+ const existing = path . join ( dirname , 'src' )
46
46
if ( ! fs . existsSync ( existing ) ) {
47
47
log ( 'tree-sitter src not found. If you are making a lang package, please run `pnpm source`.' )
48
48
return
You can’t perform that action at this time.
0 commit comments