Skip to content

Commit 68049ad

Browse files
Merge pull request DefinitelyTyped#21700 from YashdalfTheGray/master
added types for [email protected]
2 parents 9fe47c5 + 62b1ebf commit 68049ad

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
export interface CommandEntry {
7+
name: string;
8+
args: string[];
9+
lineno: number;
10+
raw: string;
11+
error?: string;
12+
}
13+
14+
export interface ParseOptions {
15+
includeComments: boolean;
16+
}
17+
18+
export function parse(
19+
contents: string,
20+
options?: ParseOptions
21+
): CommandEntry[];
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)