-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4396ac2
commit d24b63a
Showing
3 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
declare namespace pkgUp { | ||
interface Options { | ||
/** | ||
Directory to start from. | ||
@default process.cwd() | ||
*/ | ||
readonly cwd?: string; | ||
} | ||
} | ||
|
||
declare const pkgUp: { | ||
/** | ||
Find the closest `package.json` file. | ||
@returns The filepath, or `null` if it couldn't be found. | ||
@example | ||
``` | ||
// / | ||
// └── Users | ||
// └── sindresorhus | ||
// └── foo | ||
// ├── package.json | ||
// └── bar | ||
// ├── baz | ||
// └── example.js | ||
// example.js | ||
import pkgUp = require('pkg-up'); | ||
(async () => { | ||
console.log(await pkgUp()); | ||
//=> '/Users/sindresorhus/foo/package.json' | ||
})(); | ||
``` | ||
*/ | ||
(options?: pkgUp.Options): Promise<string | null>; | ||
|
||
/** | ||
Synchronously find the closest `package.json` file. | ||
@returns The filepath, or `null` if it couldn't be found. | ||
*/ | ||
sync(options?: pkgUp.Options): string | null; | ||
}; | ||
|
||
export = pkgUp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {expectType} from 'tsd'; | ||
import pkgUp = require('.'); | ||
|
||
expectType<Promise<string | null>>(pkgUp()); | ||
expectType<Promise<string | null>>(pkgUp({cwd: '.'})); | ||
expectType<string | null>(pkgUp.sync()); | ||
expectType<string | null>(pkgUp.sync({cwd: '.'})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters