diff --git a/types/isexe/index.d.ts b/types/isexe/index.d.ts new file mode 100644 index 0000000000..87f460ebdf --- /dev/null +++ b/types/isexe/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for isexe 2.0 +// Project: https://github.com/isaacs/isexe#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = isExe; + +declare function isExe(path: string, options?: isExe.Options): Promise; +declare function isExe( + path: string, + callback: (error: NodeJS.ErrnoException | undefined, isExe: boolean) => void +): void; +declare function isExe( + path: string, + options: isExe.Options, + callback: (error: NodeJS.ErrnoException | undefined, isExe: boolean) => void +): void; + +declare namespace isExe { + function sync(path: string, options?: Options): boolean; + + interface Options { + ignoreErrors?: boolean; + uid?: number; + gid?: number; + pathExt?: string; + } +} diff --git a/types/isexe/isexe-tests.ts b/types/isexe/isexe-tests.ts new file mode 100644 index 0000000000..4103c1fee7 --- /dev/null +++ b/types/isexe/isexe-tests.ts @@ -0,0 +1,18 @@ +import isexe = require('isexe'); + +isexe('some-file-name'); // $ExpectType Promise +isexe('some-file-name', { ignoreErrors: true }); // $ExpectType Promise +isexe('some-file-name', { uid: 123 }); // $ExpectType Promise +isexe('some-file-name', { gid: 123 }); // $ExpectType Promise +isexe('some-file-name', { pathExt: 'exe;bat' }); // $ExpectType Promise +isexe('some-file-name', (err, isExe) => { + err; // $ExpectType ErrnoException | undefined + isExe; // $ExpectType boolean +}); +isexe('some-file-name', { ignoreErrors: true }, (err, isExe) => { + err; // $ExpectType ErrnoException | undefined + isExe; // $ExpectType boolean +}); + +isexe.sync('some-file-name'); // $ExpectType boolean +isexe.sync('some-file-name', { ignoreErrors: true }); // $ExpectType boolean diff --git a/types/isexe/tsconfig.json b/types/isexe/tsconfig.json new file mode 100644 index 0000000000..8ddbc1ca71 --- /dev/null +++ b/types/isexe/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "isexe-tests.ts" + ] +} diff --git a/types/isexe/tslint.json b/types/isexe/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/isexe/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }