-
Notifications
You must be signed in to change notification settings - Fork 6
✨ Bash #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Bash #46
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ast-grep/lang-bash": patch | ||
--- | ||
|
||
Added @ast-grep/lang-bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# ast-grep napi language for bash | ||
|
||
## Installation | ||
|
||
In a pnpm project, run: | ||
|
||
```bash | ||
pnpm install @ast-grep/lang-bash | ||
pnpm install @ast-grep/napi | ||
# install the tree-sitter-cli if no prebuild is available | ||
pnpm install @tree-sitter/cli --save-dev | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import bash from '@ast-grep/lang-bash' | ||
import { registerDynamicLanguage, parse } from '@ast-grep/napi' | ||
|
||
registerDynamicLanguage({ bash }) | ||
|
||
const sg = parse('bash', `your code`) | ||
sg.root().kind() | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
type LanguageRegistration = { | ||
libraryPath: string | ||
extensions: string[] | ||
languageSymbol?: string | ||
metaVarChar?: string | ||
expandoChar?: string | ||
} | ||
|
||
declare const registration: LanguageRegistration | ||
export default registration |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const path = require('node:path') | ||
const libPath = path.join(__dirname, 'parser.so') | ||
|
||
module.exports = { | ||
libraryPath: libPath, | ||
extensions: [ | ||
'bash', | ||
'bats', | ||
'cgi', | ||
'command', | ||
'env', | ||
'fcgi', | ||
'ksh', | ||
'sh', | ||
'tmux', | ||
'tool', | ||
'zsh', | ||
], | ||
languageSymbol: 'tree_sitter_bash', | ||
expandoChar: '$', | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { setup } = require('@ast-grep/nursery') | ||
const assert = require('node:assert') | ||
const languageRegistration = require('./index') | ||
|
||
setup({ | ||
dirname: __dirname, | ||
name: 'bash', | ||
treeSitterPackage: 'tree-sitter-bash', | ||
languageRegistration, | ||
testRunner: parse => { | ||
const sg = parse('echo test') | ||
const root = sg.root() | ||
const node = root.find('echo $A') | ||
assert.equal(node.kind(), 'command') | ||
}, | ||
}) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "@ast-grep/lang-bash", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "tree-sitter build -o parser.so", | ||
"source": "node nursery.js source", | ||
"prepublishOnly": "node nursery.js source", | ||
"postinstall": "node postinstall.js", | ||
"test": "node nursery.js test" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"type.d.ts", | ||
"postinstall.js", | ||
"src", | ||
"prebuilds" | ||
], | ||
Comment on lines
+13
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify the existence of type.d.ts and consider adding nursery.js to files. The files list appears to include most necessary files, but has potential issues. 🏁 Script executed: #!/bin/bash
# Check if type.d.ts exists and if nursery.js is needed in the files array
# Check for type.d.ts
echo "Checking for type.d.ts file..."
if [ -f "packages/bash/type.d.ts" ]; then
echo "type.d.ts exists."
else
echo "type.d.ts is listed in files array but does not exist."
fi
# Check for nursery.js
echo "Checking for nursery.js file..."
if [ -f "packages/bash/nursery.js" ]; then
echo "nursery.js exists but is not included in the files array."
else
echo "nursery.js does not exist."
fi Length of output: 462 Action Required: Update Files Array in packages/bash/package.json
|
||
"keywords": ["ast-grep"], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@ast-grep/setup-lang": "0.0.3" | ||
}, | ||
"peerDependencies": { | ||
"tree-sitter-cli": "0.24.6" | ||
}, | ||
"peerDependenciesMeta": { | ||
"tree-sitter-cli": { | ||
"optional": true | ||
} | ||
}, | ||
"devDependencies": { | ||
"@ast-grep/nursery": "0.0.2", | ||
"tree-sitter-bash": "0.23.3", | ||
"tree-sitter-cli": "0.24.6" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"pnpm": { | ||
"onlyBuiltDependencies": ["@ast-grep/lang-bash", "tree-sitter-cli"] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const { postinstall } = require('@ast-grep/setup-lang') | ||
postinstall({ | ||
dirname: __dirname, | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.