File tree Expand file tree Collapse file tree 4 files changed +72
-0
lines changed Expand file tree Collapse file tree 4 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ import { parse , CommandEntry , ParseOptions } from 'docker-file-parser' ;
2+
3+ const file = `
4+ FROM node:8
5+
6+ ADD . /opt/
7+ WORKDIR /opt
8+
9+ RUN npm install --production
10+
11+ EXPOSE 8080
12+ VOLUME /opt/scripts
13+
14+ CMD ["npm", "start"]
15+ ` ;
16+
17+ const options : ParseOptions = {
18+ includeComments : false
19+ } ;
20+
21+ const result : CommandEntry [ ] = parse ( file , options ) ;
22+ const line1Name = result [ 0 ] . name ;
23+ const line1Number = result [ 0 ] . lineno ;
24+ const line1Args = result [ 0 ] . args ;
25+ const line1Raw = result [ 0 ] . raw ;
Original file line number Diff line number Diff line change 1+ // Type definitions for docker-file-parser 1.0
2+ // Project: https://github.com/joyent/docker-file-parse
3+ // Definitions by: Yash Kulshrestha <https://github.com/yashdalfthegray>
4+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
6+ declare module "docker-file-parser" {
7+ export interface CommandEntry {
8+ name : string ;
9+ args : string [ ] ;
10+ lineno : number ;
11+ raw : string ;
12+ error ?: string ;
13+ }
14+
15+ export interface ParseOptions {
16+ includeComments : boolean ;
17+ }
18+
19+ export function parse (
20+ contents : string ,
21+ options ?: ParseOptions
22+ ) : CommandEntry [ ] ;
23+ }
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "module" : " commonjs" ,
4+ "lib" : [
5+ " es6"
6+ ],
7+ "noImplicitAny" : true ,
8+ "noImplicitThis" : true ,
9+ "strictNullChecks" : true ,
10+ "baseUrl" : " ../" ,
11+ "typeRoots" : [
12+ " ../"
13+ ],
14+ "types" : [],
15+ "noEmit" : true ,
16+ "forceConsistentCasingInFileNames" : true ,
17+ "strictFunctionTypes" : true
18+ },
19+ "files" : [
20+ " index.d.ts" ,
21+ " docker-file-parser-tests.ts"
22+ ]
23+ }
Original file line number Diff line number Diff line change 1+ { "extends" : " dtslint/dt.json" }
You can’t perform that action at this time.
0 commit comments