diff --git a/types/find-parent-dir/find-parent-dir-tests.ts b/types/find-parent-dir/find-parent-dir-tests.ts new file mode 100644 index 0000000000..31b3307377 --- /dev/null +++ b/types/find-parent-dir/find-parent-dir-tests.ts @@ -0,0 +1,19 @@ +/// + +import findParentDir = require("find-parent-dir"); + +let parentDir: string | null; + +findParentDir(__dirname, ".git", (err, dir) => { + if (err) { + console.error("error", err); + } else { + parentDir = dir; + } +}); + +try { + parentDir = findParentDir.sync(__dirname, ".git"); +} catch (err) { + console.error("error", err); +} diff --git a/types/find-parent-dir/index.d.ts b/types/find-parent-dir/index.d.ts new file mode 100644 index 0000000000..0302255198 --- /dev/null +++ b/types/find-parent-dir/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for find-parent-dir 0.3 +// Project: https://github.com/thlorenz/find-parent-dir +// Definitions by: Ika +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Finds the first parent directory that contains a given file or directory. + */ +declare function findParentDir( + currentFullPath: string, + clue: string, + cb: (err: any, dir: string | null) => void +): void; + +declare namespace findParentDir { + function sync(currentFullPath: string, clue: string): string | null; +} + +export = findParentDir; diff --git a/types/find-parent-dir/tsconfig.json b/types/find-parent-dir/tsconfig.json new file mode 100644 index 0000000000..83c817d86c --- /dev/null +++ b/types/find-parent-dir/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "find-parent-dir-tests.ts"] +} diff --git a/types/find-parent-dir/tslint.json b/types/find-parent-dir/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/find-parent-dir/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}