Skip to content

Commit 410b6fe

Browse files
added types for docker-file-parser
1 parent 9ee5d7d commit 410b6fe

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "extends": "dtslint/dt.json" }

0 commit comments

Comments
 (0)