Skip to content

Commit 306444d

Browse files
macabeusHerringtonDarkholme
authored andcommitted
update other langs
1 parent 33bda95 commit 306444d

File tree

27 files changed

+648
-54
lines changed

27 files changed

+648
-54
lines changed

packages/angular/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['html'],
729
languageSymbol: 'tree_sitter_angular',
830
expandoChar: 'z',

packages/bash/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: [
729
'bash',
830
'bats',

packages/cpp/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['cc', 'hpp', 'cpp', 'hh', 'cxx', 'cu', 'ino'],
729
languageSymbol: 'tree_sitter_cpp',
830
expandoChar: '_',

packages/csharp/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['cs'],
729
languageSymbol: 'tree_sitter_c_sharp',
830
expandoChar: 'µ',

packages/css/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['css', 'scss'],
729
languageSymbol: 'tree_sitter_css',
830
expandoChar: '$',

packages/dart/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['dart'],
729
languageSymbol: 'tree_sitter_dart',
830
expandoChar: '$',

packages/elixir/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['ex', 'exs'],
729
languageSymbol: 'tree_sitter_elixir',
830
expandoChar: 'µ',

packages/go/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['go'],
729
languageSymbol: 'tree_sitter_go',
830
expandoChar: 'µ',

packages/haskell/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['hs'],
729
languageSymbol: 'tree_sitter_haskell',
830
expandoChar: 'µ',

packages/html/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
const fs = require('node:fs')
3+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
4+
5+
function getLibPath() {
6+
const prebuild = resolvePrebuild(__dirname)
7+
if (prebuild) {
8+
return prebuild;
9+
}
10+
11+
const native = path.join(__dirname, 'parser.so');
12+
if (fs.existsSync(native)) {
13+
return native;
14+
}
15+
16+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.');
17+
}
18+
19+
let libPath;
320

421
module.exports = {
5-
libraryPath: libPath,
22+
get libraryPath() {
23+
if (!libPath) {
24+
libPath = getLibPath();
25+
}
26+
return libPath;
27+
},
628
extensions: ['html', 'htm', 'xhtml'],
729
languageSymbol: 'tree_sitter_html',
830
expandoChar: 'z',

0 commit comments

Comments
 (0)