diff --git a/types/npm-packlist/index.d.ts b/types/npm-packlist/index.d.ts new file mode 100644 index 0000000000..934d2f8967 --- /dev/null +++ b/types/npm-packlist/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for npm-packlist 1.1 +// Project: https://github.com/npm/npm-packlist +// Definitions by: Klaus Meinhardt +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +declare function packlist(options?: packlist.Options): Promise; +declare function packlist(options: packlist.Options | undefined, callback: (result: string[]) => T): Promise; +declare namespace packlist { + interface Options { + /** Directory to walk recusively. Defaults to `process.cwd()`. */ + path?: string; + } + function sync(options?: Options): string[]; +} +export = packlist; diff --git a/types/npm-packlist/npm-packlist-tests.ts b/types/npm-packlist/npm-packlist-tests.ts new file mode 100644 index 0000000000..162a7d86f5 --- /dev/null +++ b/types/npm-packlist/npm-packlist-tests.ts @@ -0,0 +1,14 @@ +import packlist = require('npm-packlist'); + +let result: string[] = packlist.sync(); +result = packlist.sync({}); +result = packlist.sync({path: 'foo'}); + +(async () => { + result = await packlist(); + result = await packlist({}); + result = await packlist({path: 'foo'}); + + packlist(undefined, (r) => result = r); + packlist({path: 'foo'}, (r) => result = r); +})(); diff --git a/types/npm-packlist/tsconfig.json b/types/npm-packlist/tsconfig.json new file mode 100644 index 0000000000..29834afe3e --- /dev/null +++ b/types/npm-packlist/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "esModuleInterop": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "npm-packlist-tests.ts" + ] +} diff --git a/types/npm-packlist/tslint.json b/types/npm-packlist/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-packlist/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }