diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 1a9d175..f398f2d 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,42 +1,39 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
{
- "name": "Node.js",
- // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
- "image": "mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm",
+ "name": "Node.js",
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
+ "image": "mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm",
- // Features to add to the dev container. More info: https://containers.dev/features.
- // "features": {
- // "ghcr.io/devcontainers/features/go:1": {}
- // },
+ // Features to add to the dev container. More info: https://containers.dev/features.
+ // "features": {
+ // "ghcr.io/devcontainers/features/go:1": {}
+ // },
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
- // "forwardPorts": [],
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ // "forwardPorts": [],
- // Use 'postCreateCommand' to run commands after the container is created.
- "postCreateCommand": {
- "Configure Build Tools": "npm install -g pnpm"
- },
+ // Use 'postCreateCommand' to run commands after the container is created.
+ "postCreateCommand": {
+ "Configure Build Tools": "npm install -g pnpm"
+ },
- // Configure tool-specific properties.
- "customizations": {
- "vscode": {
- "settings": {
- "terminal.integrated.defaultProfile.linux": "bash",
- "terminal.integrated.profiles.linux": {
- "bash": {
- "path": "/bin/bash",
- "icon": "terminal-bash"
- }
- }
- },
- "extensions": [
- "dbaeumer.vscode-eslint",
- "dprint.dprint"
- ]
+ // Configure tool-specific properties.
+ "customizations": {
+ "vscode": {
+ "settings": {
+ "terminal.integrated.defaultProfile.linux": "bash",
+ "terminal.integrated.profiles.linux": {
+ "bash": {
+ "path": "/bin/bash",
+ "icon": "terminal-bash"
+ }
}
- },
+ },
+ "extensions": ["dbaeumer.vscode-eslint", "dprint.dprint"]
+ }
+ },
- // More info: https://aka.ms/dev-containers-non-root.
- "remoteUser": "node"
+ // More info: https://aka.ms/dev-containers-non-root.
+ "remoteUser": "node"
}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6ee7861..1a23e66 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,4 +24,6 @@ jobs:
- name: Install dependencies
run: pnpm install --ignore-scripts
- name: Run linting/formatting checks
- run: pnpm lint:ci
+ run: |
+ pnpm lint:ci
+ pnpm format:ci
diff --git a/biome.json b/biome.json
index 15fa951..8ca9270 100644
--- a/biome.json
+++ b/biome.json
@@ -1,33 +1,36 @@
{
- "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": true
- },
- "files": {
- "ignoreUnknown": false,
- "ignore": []
- },
- "formatter": {
- "enabled": true,
- "indentStyle": "tab"
- },
- "organizeImports": {
- "enabled": true
- },
- "linter": {
- "enabled": true,
- "rules": {
- "recommended": true,
+ "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
+ "vcs": {
+ "enabled": true,
+ "clientKind": "git",
+ "useIgnoreFile": true
+ },
+ "files": {
+ "ignoreUnknown": false,
+ "ignore": []
+ },
+ "formatter": {
+ "enabled": true,
+ "indentStyle": "space"
+ },
+ "organizeImports": {
+ "enabled": true
+ },
+ "linter": {
+ "enabled": true,
+ "rules": {
+ "recommended": true,
"style": {
"useTemplate": "off"
}
- }
- },
- "javascript": {
- "formatter": {
- "quoteStyle": "single"
- }
- }
+ }
+ },
+ "javascript": {
+ "formatter": {
+ "arrowParentheses": "asNeeded",
+ "quoteStyle": "single",
+ "semicolons": "asNeeded",
+ "trailingCommas": "all"
+ }
+ }
}
diff --git a/package.json b/package.json
index aa24f2f..f43e1c5 100644
--- a/package.json
+++ b/package.json
@@ -1,14 +1,13 @@
{
"name": "@ast-grep/langs",
"private": true,
- "workspaces": [
- "packages/*",
- "scripts/*"
- ],
+ "workspaces": ["packages/*", "scripts/*"],
"version": "0.0.1",
"description": "Monorepo for `@ast-grep/lang-*` packages",
"scripts": {
"postinstall": "pnpm -r compile-ts",
+ "format": "biome format --write",
+ "format:ci": "biome format",
"lint": "biome lint --fix",
"lint:ci": "biome lint",
"prepare": "husky"
@@ -21,8 +20,6 @@
"husky": "9.1.7"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["tree-sitter-cli"]
}
}
diff --git a/packages/angular/index.js b/packages/angular/index.js
index d8462e5..b090f1f 100644
--- a/packages/angular/index.js
+++ b/packages/angular/index.js
@@ -3,7 +3,7 @@ const libPath = path.join(__dirname, 'parser.so')
module.exports = {
libraryPath: libPath,
- extensions: ["html"],
+ extensions: ['html'],
languageSymbol: 'tree_sitter_angular',
expandoChar: 'z',
}
diff --git a/packages/angular/nursery.js b/packages/angular/nursery.js
index 2eb9fc7..803059d 100644
--- a/packages/angular/nursery.js
+++ b/packages/angular/nursery.js
@@ -6,9 +6,9 @@ setup({
name: 'angular',
treeSitterPackage: 'tree-sitter-angular',
languageRegistration,
- testRunner: (parse) => {
+ testRunner: parse => {
const a = parse('
')
const b = a.root().find('<$TAG>$TAG>')
console.log(b.kind(), b.getMatch('TAG').text())
- }
+ },
})
diff --git a/packages/angular/package.json b/packages/angular/package.json
index 8fd3619..25849ef 100644
--- a/packages/angular/package.json
+++ b/packages/angular/package.json
@@ -18,10 +18,7 @@
"src",
"prebuilds"
],
- "keywords": [
- "ast-grep",
- "ast-grep-lang"
- ],
+ "keywords": ["ast-grep", "ast-grep-lang"],
"author": "",
"license": "ISC",
"dependencies": {
@@ -45,8 +42,6 @@
"registry": "https://registry.npmjs.org/"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["tree-sitter-cli"]
}
}
diff --git a/packages/c/index.js b/packages/c/index.js
index 23a0fcb..51477c6 100644
--- a/packages/c/index.js
+++ b/packages/c/index.js
@@ -3,7 +3,7 @@ const libPath = path.join(__dirname, 'parser.so')
module.exports = {
libraryPath: libPath,
- extensions: ["c","h"],
+ extensions: ['c', 'h'],
languageSymbol: 'tree_sitter_c',
expandoChar: '_',
}
diff --git a/packages/c/nursery.js b/packages/c/nursery.js
index 9abaaa0..2c9f39e 100644
--- a/packages/c/nursery.js
+++ b/packages/c/nursery.js
@@ -7,10 +7,10 @@ setup({
name: 'c',
treeSitterPackage: 'tree-sitter-c',
languageRegistration,
- testRunner: (parse) => {
+ testRunner: parse => {
const sg = parse('int a = 123;')
const root = sg.root()
const node = root.find('$T $A = 123')
assert.equal(node.kind(), 'declaration')
- }
+ },
})
diff --git a/packages/c/package.json b/packages/c/package.json
index 4a7d532..6380d3f 100644
--- a/packages/c/package.json
+++ b/packages/c/package.json
@@ -18,10 +18,7 @@
"src",
"prebuilds"
],
- "keywords": [
- "ast-grep",
- "ast-grep-lang"
- ],
+ "keywords": ["ast-grep", "ast-grep-lang"],
"author": "",
"license": "ISC",
"dependencies": {
@@ -45,9 +42,6 @@
"registry": "https://registry.npmjs.org/"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "@ast-grep/lang-c",
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["@ast-grep/lang-c", "tree-sitter-cli"]
}
}
diff --git a/packages/cpp/index.js b/packages/cpp/index.js
index 7a83b24..78037f6 100644
--- a/packages/cpp/index.js
+++ b/packages/cpp/index.js
@@ -3,7 +3,7 @@ const libPath = path.join(__dirname, 'parser.so')
module.exports = {
libraryPath: libPath,
- extensions: ["cc","hpp","cpp","hh","cxx","cu","ino"],
+ extensions: ['cc', 'hpp', 'cpp', 'hh', 'cxx', 'cu', 'ino'],
languageSymbol: 'tree_sitter_cpp',
expandoChar: '_',
}
diff --git a/packages/cpp/nursery.js b/packages/cpp/nursery.js
index 9b09f1b..196f66b 100644
--- a/packages/cpp/nursery.js
+++ b/packages/cpp/nursery.js
@@ -7,7 +7,7 @@ setup({
name: 'cpp',
treeSitterPackage: 'tree-sitter-cpp',
languageRegistration,
- testRunner: (parse) => {
+ testRunner: parse => {
const sg = parse(`
template
T add(T a, T b) {
@@ -22,5 +22,5 @@ setup({
const root = sg.root()
const node = root.find('$T $A = 123')
assert.equal(node.kind(), 'declaration')
- }
+ },
})
diff --git a/packages/cpp/package.json b/packages/cpp/package.json
index a71d4c8..8e87072 100644
--- a/packages/cpp/package.json
+++ b/packages/cpp/package.json
@@ -18,10 +18,7 @@
"src",
"prebuilds"
],
- "keywords": [
- "ast-grep",
- "ast-grep-lang"
- ],
+ "keywords": ["ast-grep", "ast-grep-lang"],
"author": "",
"license": "ISC",
"dependencies": {
@@ -45,9 +42,6 @@
"registry": "https://registry.npmjs.org/"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "@ast-grep/lang-cpp",
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["@ast-grep/lang-cpp", "tree-sitter-cli"]
}
}
diff --git a/packages/csharp/index.js b/packages/csharp/index.js
index 838b74e..b7f177b 100644
--- a/packages/csharp/index.js
+++ b/packages/csharp/index.js
@@ -3,7 +3,7 @@ const libPath = path.join(__dirname, 'parser.so')
module.exports = {
libraryPath: libPath,
- extensions: ["cs"],
+ extensions: ['cs'],
languageSymbol: 'tree_sitter_c_sharp',
expandoChar: 'µ',
}
diff --git a/packages/csharp/nursery.js b/packages/csharp/nursery.js
index 7099f46..46e2f8c 100644
--- a/packages/csharp/nursery.js
+++ b/packages/csharp/nursery.js
@@ -7,10 +7,10 @@ setup({
name: 'csharp',
treeSitterPackage: 'tree-sitter-c-sharp',
languageRegistration,
- testRunner: (parse) => {
+ testRunner: parse => {
const sg = parse('var a = 123;')
const root = sg.root()
const node = root.find('var $A = 123')
assert.equal(node.kind(), 'variable_declaration')
- }
+ },
})
diff --git a/packages/csharp/package.json b/packages/csharp/package.json
index 808381d..5289000 100644
--- a/packages/csharp/package.json
+++ b/packages/csharp/package.json
@@ -18,10 +18,7 @@
"src",
"prebuilds"
],
- "keywords": [
- "ast-grep",
- "ast-grep-lang"
- ],
+ "keywords": ["ast-grep", "ast-grep-lang"],
"author": "",
"license": "ISC",
"dependencies": {
@@ -45,9 +42,6 @@
"registry": "https://registry.npmjs.org/"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "@ast-grep/lang-csharp",
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["@ast-grep/lang-csharp", "tree-sitter-cli"]
}
}
diff --git a/packages/python/index.js b/packages/python/index.js
index 44b4301..cc6f1aa 100644
--- a/packages/python/index.js
+++ b/packages/python/index.js
@@ -3,7 +3,7 @@ const libPath = path.join(__dirname, 'parser.so')
module.exports = {
libraryPath: libPath,
- extensions: ["py"],
+ extensions: ['py'],
languageSymbol: 'tree_sitter_python',
expandoChar: 'µ',
}
diff --git a/packages/python/nursery.js b/packages/python/nursery.js
index 809a4f8..69441dd 100644
--- a/packages/python/nursery.js
+++ b/packages/python/nursery.js
@@ -7,10 +7,10 @@ setup({
name: 'python',
treeSitterPackage: 'tree-sitter-python',
languageRegistration,
- testRunner: (parse) => {
+ testRunner: parse => {
const sg = parse('a = 123')
const root = sg.root()
const node = root.find('$FIELD = 123')
assert.equal(node.kind(), 'assignment')
- }
+ },
})
diff --git a/packages/python/package.json b/packages/python/package.json
index f3c31b9..aa65ef9 100644
--- a/packages/python/package.json
+++ b/packages/python/package.json
@@ -18,10 +18,7 @@
"src",
"prebuilds"
],
- "keywords": [
- "ast-grep",
- "ast-grep-lang"
- ],
+ "keywords": ["ast-grep", "ast-grep-lang"],
"author": "",
"license": "ISC",
"dependencies": {
@@ -45,9 +42,6 @@
"registry": "https://registry.npmjs.org/"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "@ast-grep/lang-python",
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["@ast-grep/lang-python", "tree-sitter-cli"]
}
}
diff --git a/packages/sql/index.js b/packages/sql/index.js
index ddcc9e4..5752ec1 100644
--- a/packages/sql/index.js
+++ b/packages/sql/index.js
@@ -3,7 +3,7 @@ const libPath = path.join(__dirname, 'parser.so')
module.exports = {
libraryPath: libPath,
- extensions: ["sql"],
+ extensions: ['sql'],
languageSymbol: 'tree_sitter_sql',
expandoChar: '_',
}
diff --git a/packages/sql/nursery.js b/packages/sql/nursery.js
index 9082403..63e4fb5 100644
--- a/packages/sql/nursery.js
+++ b/packages/sql/nursery.js
@@ -6,7 +6,7 @@ setup({
name: 'sql',
treeSitterPackage: '@derekstride/tree-sitter-sql',
languageRegistration,
- testRunner: (parse) => {
+ testRunner: parse => {
// add test here
- }
+ },
})
diff --git a/packages/sql/package.json b/packages/sql/package.json
index 0f782cc..ff7aa1e 100644
--- a/packages/sql/package.json
+++ b/packages/sql/package.json
@@ -18,10 +18,7 @@
"src",
"prebuilds"
],
- "keywords": [
- "ast-grep",
- "ast-grep-lang"
- ],
+ "keywords": ["ast-grep", "ast-grep-lang"],
"author": "",
"license": "ISC",
"dependencies": {
@@ -45,8 +42,6 @@
"registry": "https://registry.npmjs.org/"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["tree-sitter-cli"]
}
}
diff --git a/packages/toml/nursery.js b/packages/toml/nursery.js
index b9aa674..5aa4cc1 100644
--- a/packages/toml/nursery.js
+++ b/packages/toml/nursery.js
@@ -7,10 +7,10 @@ setup({
name: 'toml',
treeSitterPackage: '@tree-sitter-grammars/tree-sitter-toml',
languageRegistration: toml,
- testRunner: (parse) => {
+ testRunner: parse => {
const sg = parse('name = "Tom"')
const root = sg.root()
const pair = root.find('$NAME = "Tom"')
assert.equal(pair.kind(), 'pair')
- }
+ },
})
diff --git a/packages/toml/package.json b/packages/toml/package.json
index b7422e4..24ac8dc 100644
--- a/packages/toml/package.json
+++ b/packages/toml/package.json
@@ -18,10 +18,7 @@
"src",
"prebuilds"
],
- "keywords": [
- "ast-grep",
- "ast-grep-lang"
- ],
+ "keywords": ["ast-grep", "ast-grep-lang"],
"author": "",
"license": "ISC",
"dependencies": {
@@ -45,8 +42,6 @@
"registry": "https://registry.npmjs.org/"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["tree-sitter-cli"]
}
}
diff --git a/renovate.json b/renovate.json
index 5db72dd..22a9943 100644
--- a/renovate.json
+++ b/renovate.json
@@ -1,6 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
- "extends": [
- "config:recommended"
- ]
+ "extends": ["config:recommended"]
}
diff --git a/scripts/create-lang/index.ts b/scripts/create-lang/index.ts
index 2f51dca..f597588 100644
--- a/scripts/create-lang/index.ts
+++ b/scripts/create-lang/index.ts
@@ -12,61 +12,67 @@ function required(s: string): string | true {
// https://github.com/vitejs/vite/blob/76082e3d3033b09b02b6db64de6e36942593c753/packages/create-vite/src/index.ts#L557
function isValidPackageName(projectName: string) {
- return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(
- projectName,
- ) || 'Invalid package name'
+ return (
+ /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(
+ projectName,
+ ) || 'Invalid package name'
+ )
}
-
function askConfiguration() {
- return prompts([
- {
- type: 'text',
- name: 'name',
- message: 'Language name',
- validate: required,
- },
- {
- type: 'text',
- name: 'packageName',
- message: 'Package name',
- validate: isValidPackageName,
- initial: (_, answers) => `my-dynamic-lang-${answers.name}`,
- },
- {
- type: 'text',
- name: 'treeSitterPackage',
- message: 'Tree-sitter package to use',
- validate: isValidPackageName,
- initial: (_, answers) => `tree-sitter-${answers.name}`,
- },
+ return prompts(
+ [
+ {
+ type: 'text',
+ name: 'name',
+ message: 'Language name',
+ validate: required,
+ },
+ {
+ type: 'text',
+ name: 'packageName',
+ message: 'Package name',
+ validate: isValidPackageName,
+ initial: (_, answers) => `my-dynamic-lang-${answers.name}`,
+ },
+ {
+ type: 'text',
+ name: 'treeSitterPackage',
+ message: 'Tree-sitter package to use',
+ validate: isValidPackageName,
+ initial: (_, answers) => `tree-sitter-${answers.name}`,
+ },
+ {
+ type: 'list',
+ name: 'extensions',
+ message: 'File extensions used by the language, comma separated',
+ separator: ',',
+ validate: required,
+ },
+ {
+ type: 'text',
+ name: 'expandoChar',
+ message: 'Expando char used in pattern',
+ initial: '$',
+ validate: value => {
+ return value.length === 1
+ ? true
+ : 'Expando char must be a single character'
+ },
+ },
+ {
+ type: 'confirm',
+ name: 'includeDotFiles',
+ message: 'Include gitignore and npm publish files?',
+ initial: true,
+ },
+ ],
{
- type: 'list',
- name: 'extensions',
- message: 'File extensions used by the language, comma separated',
- separator: ',',
- validate: required,
+ onCancel: () => {
+ process.exit(1)
+ },
},
- {
- type: 'text',
- name: 'expandoChar',
- message: 'Expando char used in pattern',
- initial: '$',
- validate: (value) => {
- return value.length === 1 ? true : 'Expando char must be a single character'
- }
- },
- {
- type: 'confirm',
- name: 'includeDotFiles',
- message: 'Include gitignore and npm publish files?',
- initial: true,
- }
- ], {
- onCancel: () => {
- process.exit(1)
- }
- })
+ )
}
type Answers = Awaited>
@@ -74,12 +80,12 @@ type Answers = Awaited>
function copyTemplate(targetDir: string, includeDotFiles: boolean) {
const templateDir = path.join(__dirname, 'template')
return fs.cp(templateDir, targetDir, {
- recursive: true, // Copy all files and folders
+ recursive: true, // Copy all files and folders
// includes hidden files if `includeDotFiles` is true
- filter: (src) => {
+ filter: src => {
const basename = path.basename(src)
return includeDotFiles || !basename.startsWith('.')
- }
+ },
})
}
@@ -98,7 +104,7 @@ async function renameFiles(dir: string, answer: Answers) {
renameFiles(filePath, answer)
} else {
const content = await fs.readFile(filePath, 'utf-8')
- const newContent = content.replace(/(\$\$[A-Z_]+\$\$)/g, (match) => {
+ const newContent = content.replace(/(\$\$[A-Z_]+\$\$)/g, match => {
return name[match] || match
})
await fs.writeFile(filePath, newContent)
diff --git a/scripts/create-lang/template/package.json b/scripts/create-lang/template/package.json
index da0a8bc..3cc1ae5 100644
--- a/scripts/create-lang/template/package.json
+++ b/scripts/create-lang/template/package.json
@@ -18,10 +18,7 @@
"src",
"prebuilds"
],
- "keywords": [
- "ast-grep",
- "ast-grep-lang"
- ],
+ "keywords": ["ast-grep", "ast-grep-lang"],
"author": "",
"license": "ISC",
"dependencies": {
@@ -44,9 +41,6 @@
"registry": "https://registry.npmjs.org/"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "$$PACKAGE_NAME$$",
- "tree-sitter-cli"
- ]
+ "onlyBuiltDependencies": ["$$PACKAGE_NAME$$", "tree-sitter-cli"]
}
}
diff --git a/scripts/nursery/index.ts b/scripts/nursery/index.ts
index 902dbd0..de7ab89 100644
--- a/scripts/nursery/index.ts
+++ b/scripts/nursery/index.ts
@@ -1,6 +1,7 @@
+import type { DynamicLangRegistrations, SgRoot } from '@ast-grep/napi'
+import { parse, registerDynamicLanguage } from '@ast-grep/napi'
import fs from 'node:fs'
import path from 'node:path'
-import { parse, registerDynamicLanguage, type SgRoot, type DynamicLangRegistrations } from '@ast-grep/napi'
/**
* Log to console
@@ -26,7 +27,7 @@ interface SetupConfig {
function test(setupConfig: SetupConfig) {
const { name, languageRegistration, testRunner } = setupConfig
registerDynamicLanguage({ [name]: languageRegistration })
- testRunner((code) => parse(name, code))
+ testRunner(code => parse(name, code))
}
/** Setup ast-grep/lang package's pre-release build and test */
@@ -43,7 +44,7 @@ export function setup(setupConfig: SetupConfig) {
function copySrcIfNeeded(config: SetupConfig) {
const { dirname, treeSitterPackage } = config
const existing = path.join(dirname, 'src')
- const src = path.join(dirname, 'node_modules', treeSitterPackage, 'src')
+ const src = path.join(dirname, 'node_modules', treeSitterPackage, 'src')
if (fs.existsSync(existing)) {
log('src exists, skipping copy')
return
diff --git a/scripts/setup/index.ts b/scripts/setup/index.ts
index d926c5d..96ce6a8 100644
--- a/scripts/setup/index.ts
+++ b/scripts/setup/index.ts
@@ -33,7 +33,9 @@ function postinstall(config: SetupConfig) {
try {
buildSrc(config)
} catch (e: unknown) {
- log('build failed, please ensure tree-sitter-cli is installed as peer dependency')
+ log(
+ 'build failed, please ensure tree-sitter-cli is installed as peer dependency',
+ )
log(e)
}
}
@@ -42,7 +44,9 @@ function buildSrc(config: SetupConfig) {
const { dirname } = config
const existing = path.join(dirname, 'src')
if (!fs.existsSync(existing)) {
- log('tree-sitter src not found. If you are making a lang package, please run `pnpm source`.')
+ log(
+ 'tree-sitter src not found. If you are making a lang package, please run `pnpm source`.',
+ )
return
}
log('building parser from source')
@@ -66,7 +70,12 @@ const ARCH_MAP: Record = {
function resolvePrebuild(dir: string) {
const os = PLATFORM_MAP[process.platform]
const arch = ARCH_MAP[process.arch]
- const prebuild = path.join(dir, 'prebuilds', `prebuild-${os}-${arch}`, 'parser.so')
+ const prebuild = path.join(
+ dir,
+ 'prebuilds',
+ `prebuild-${os}-${arch}`,
+ 'parser.so',
+ )
if (!os || !arch || !fs.existsSync(prebuild)) {
log(`no prebuild for ${os} ${arch}`)
return undefined
diff --git a/tsconfig.json b/tsconfig.json
index 5878492..9437068 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,8 +9,5 @@
"declaration": true,
"forceConsistentCasingInFileNames": true
},
- "exclude": [
- "node_modules",
- "dist"
- ]
+ "exclude": ["node_modules", "dist"]
}