feat(find-parent-dir): initial commit (#27290)

This commit is contained in:
Ika 2018-07-16 03:34:50 +08:00 committed by Ryan Cavanaugh
parent c3293bdfe3
commit 40ed9ae071
4 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,19 @@
/// <reference types="node" />
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);
}

19
types/find-parent-dir/index.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
// Type definitions for find-parent-dir 0.3
// Project: https://github.com/thlorenz/find-parent-dir
// Definitions by: Ika <https://github.com/ikatyang>
// 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;

View File

@ -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"]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}