Skip to content

Commit c994eb1

Browse files
🤖 Merge PR DefinitelyTyped#51966 update(find-project-root): missing constants by @peterblazejewicz
* update(find-project-root): missing constants - `MAX_DEPTH` - `MARKERS` https://github.com/kirstein/find-project-root/blob/master/index.js#L32-L33 Thanks! * Update types/find-project-root/index.d.ts Co-authored-by: Ika <[email protected]> * Update types/find-project-root/find-project-root-tests.ts Co-authored-by: Ika <[email protected]>
1 parent 663a0d7 commit c994eb1

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
/// <reference types="node" />
2-
31
import findProjectRoot = require("find-project-root");
42

5-
const root: string | null = findProjectRoot(process.cwd(), {
6-
maxDepth: 12
3+
const root: string | null = findProjectRoot("./", {
4+
maxDepth: 12,
5+
});
6+
7+
findProjectRoot.MARKERS; // $ExpectType [".git", ".hg"]
8+
findProjectRoot.MAX_DEPTH; // $ExpectType 9
9+
10+
// $ExpectType string | null
11+
findProjectRoot("./", {
12+
maxDepth: findProjectRoot.MAX_DEPTH,
13+
markers: findProjectRoot.MARKERS,
714
});

‎types/find-project-root/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
/**
77
* Finds the project root by custom markers
88
*/
9-
declare function findProjectRoot(
10-
path: string,
11-
options?: findProjectRoot.Options
12-
): null | string;
9+
declare function findProjectRoot(path: string, options?: findProjectRoot.Options): null | string;
1310

1411
declare namespace findProjectRoot {
1512
interface Options {
@@ -22,6 +19,9 @@ declare namespace findProjectRoot {
2219
*/
2320
markers?: string[];
2421
}
22+
23+
const MAX_DEPTH: 9;
24+
const MARKERS: [".git", ".hg"];
2525
}
2626

2727
export = findProjectRoot;

0 commit comments

Comments
 (0)