From 50b9bcf26124ef213873ceb9e5ed8891f30ac08d Mon Sep 17 00:00:00 2001 From: Ciffelia Date: Tue, 11 Feb 2020 03:40:49 +0900 Subject: [PATCH] Add type definitions for docker-events (#42217) --- types/docker-events/docker-events-tests.ts | 13 ++++++++++++ types/docker-events/index.d.ts | 24 ++++++++++++++++++++++ types/docker-events/tsconfig.json | 23 +++++++++++++++++++++ types/docker-events/tslint.json | 1 + 4 files changed, 61 insertions(+) create mode 100644 types/docker-events/docker-events-tests.ts create mode 100644 types/docker-events/index.d.ts create mode 100644 types/docker-events/tsconfig.json create mode 100644 types/docker-events/tslint.json diff --git a/types/docker-events/docker-events-tests.ts b/types/docker-events/docker-events-tests.ts new file mode 100644 index 00000000000000..9d31d051557ef4 --- /dev/null +++ b/types/docker-events/docker-events-tests.ts @@ -0,0 +1,13 @@ +import * as Dockerode from 'dockerode'; +import * as DockerEvents from 'docker-events'; + +const emitter = new DockerEvents({ + docker: new Dockerode(), +}); + +emitter.on('destroy', (message: object) => { + console.log('Container destroyed: %j', message); + emitter.stop(); +}); + +emitter.start(); diff --git a/types/docker-events/index.d.ts b/types/docker-events/index.d.ts new file mode 100644 index 00000000000000..0d6bfeb15b54a8 --- /dev/null +++ b/types/docker-events/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for docker-events 0.0 +// Project: https://github.com/deoxxa/docker-events +// Definitions by: Ciffelia +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as events from 'events'; +import * as Dockerode from 'dockerode'; + +declare namespace DockerEvents { + interface DockerEventsOptions { + docker: Dockerode; + } +} + +declare class DockerEvents extends events.EventEmitter { + constructor(options?: DockerEvents.DockerEventsOptions); + + start(): void; + stop(): void; +} + +export = DockerEvents; diff --git a/types/docker-events/tsconfig.json b/types/docker-events/tsconfig.json new file mode 100644 index 00000000000000..7ea059b5803ff4 --- /dev/null +++ b/types/docker-events/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "docker-events-tests.ts" + ] +} diff --git a/types/docker-events/tslint.json b/types/docker-events/tslint.json new file mode 100644 index 00000000000000..3db14f85eaf7b9 --- /dev/null +++ b/types/docker-events/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }