ast-grep-lang-dockerfile
v0.1.0
Published
ast-grep language support for Dockerfile
Maintainers
Readme
ast-grep-lang-dockerfile
ast-grep language support for Dockerfile, using tree-sitter-containerfile.
Installation
npm install ast-grep-lang-dockerfile
# or
bun add ast-grep-lang-dockerfileUsage with CLI
Add to your sgconfig.yml:
customLanguages:
dockerfile:
libraryPath: node_modules/ast-grep-lang-dockerfile/parser.so
extensions: [Dockerfile, .dockerfile]
languageSymbol: tree_sitter_containerfile
expandoChar: $Then use ast-grep as usual:
sg run -l dockerfile -p 'FROM $IMG' .Usage with NAPI
import dockerfile from 'ast-grep-lang-dockerfile'
import { registerDynamicLanguage, parse } from '@ast-grep/napi'
registerDynamicLanguage({ dockerfile })
const sg = parse('dockerfile', `FROM node:18
RUN npm install
CMD ["node", "app.js"]`)
console.log(sg.root().kind()) // source_fileBuilding from source
If no prebuild is available for your platform, the package will attempt to build the parser from source during installation. This requires tree-sitter-cli:
npm install tree-sitter-cli --save-dev