Package Exports
- dockerfile-ast
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dockerfile-ast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Dockerfile AST
The dockerfile-ast NPM module is a Dockerfile parser written in TypeScript.
The module provides full programmatic access to a parsed Dockerfile.
Supported features:
- escaped newline detection
escapeparser directive considered when parsing
- comments preserved
- inlined comments in multiline instructions preserved
- continuous empty newlines honoured (albeit discouraged as of Docker CE 17.09)
ARGandENVvariable lookup and resolution
Unsupported:
\ras a a line delimiter- only
\r\nand\nare supported as being line delimiters - if a
\ris detected the parser assumes that it is followed by a\n
- only
Development Instructions
If you wish to build and compile this language server, you must first install Node.js if you have not already done so. After you have installed Node.js and cloned the repository with Git, you may now proceed to build and compile the language server with the following commands:
npm install
npm run build
npm testIf you are planning to change the code, use npm run watch to get the
TypeScript files transpiled on-the-fly as they are modified.
Once the code has finished compiling, you can connect a language server client to the server via Node IPC, stdio, or sockets.
Installation Instructions
To add this library as a dependency to your project, please add dockerfile-ast as a dependency in your package.json file.
Using this Module
import { DockerfileParser } from 'dockerfile-ast';
const content =
`FROM alpine
ExposE 8080`
let dockerfile = DockerfileParser.parse(content);
let instructions = dockerfile.getInstructions();
for (let instruction in instructions) {
// FROM
// EXPOSE
console.log(instruction.getKeyword());
// FROM
// ExposE
console.log(instruction.getInstruction());
}