-
-
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.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
aa84553
commit 1bca773
Showing
9 changed files
with
99 additions
and
94 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,48 +1,59 @@ | ||
declare namespace pkgUp { | ||
interface Options { | ||
/** | ||
Directory to start from. | ||
@default process.cwd() | ||
*/ | ||
readonly cwd?: string; | ||
} | ||
} | ||
|
||
declare const pkgUp: { | ||
export interface Options { | ||
/** | ||
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>; | ||
The directory to start from. | ||
/** | ||
Synchronously find the closest `package.json` file. | ||
@returns The filepath, or `null` if it couldn't be found. | ||
@default process.cwd() | ||
*/ | ||
sync(options?: pkgUp.Options): string | null; | ||
}; | ||
readonly cwd?: string; | ||
} | ||
|
||
/** | ||
Find the closest `package.json` file. | ||
@returns The file path, or `undefined` if it could not be found. | ||
@example | ||
``` | ||
// / | ||
// └── Users | ||
// └── sindresorhus | ||
// └── foo | ||
// ├── package.json | ||
// └── bar | ||
// ├── baz | ||
// └── example.js | ||
// example.js | ||
import {pkgUp} from 'pkg-up'; | ||
console.log(await pkgUp()); | ||
//=> '/Users/sindresorhus/foo/package.json' | ||
``` | ||
*/ | ||
export function pkgUp(options?: Options): Promise<string | undefined>; | ||
|
||
/** | ||
Synchronously find the closest `package.json` file. | ||
@returns The file path, or `undefined` if it could not be found. | ||
@example | ||
``` | ||
// / | ||
// └── Users | ||
// └── sindresorhus | ||
// └── foo | ||
// ├── package.json | ||
// └── bar | ||
// ├── baz | ||
// └── example.js | ||
// example.js | ||
import {pkgUpSync} from 'pkg-up'; | ||
console.log(pkgUpSync()); | ||
//=> '/Users/sindresorhus/foo/package.json' | ||
``` | ||
*/ | ||
export function pkgUpSync(options?: Options): string | undefined; | ||
|
||
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
'use strict'; | ||
const findUp = require('find-up'); | ||
import {findUp, findUpSync} from 'find-up'; | ||
|
||
module.exports = async ({cwd} = {}) => findUp('package.json', {cwd}); | ||
module.exports.sync = ({cwd} = {}) => findUp.sync('package.json', {cwd}); | ||
export async function pkgUp({cwd} = {}) { | ||
return findUp('package.json', {cwd}); | ||
} | ||
|
||
export function pkgUpSync({cwd} = {}) { | ||
return findUpSync('package.json', {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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {expectType} from 'tsd'; | ||
import pkgUp = require('.'); | ||
import {pkgUp, pkgUpSync} from './index.js'; | ||
|
||
expectType<Promise<string | null>>(pkgUp()); | ||
expectType<Promise<string | null>>(pkgUp({cwd: '.'})); | ||
expectType<string | null>(pkgUp.sync()); | ||
expectType<string | null>(pkgUp.sync({cwd: '.'})); | ||
expectType<Promise<string | undefined>>(pkgUp()); | ||
expectType<Promise<string | undefined>>(pkgUp({cwd: '.'})); | ||
expectType<string | undefined>(pkgUpSync()); | ||
expectType<string | undefined>(pkgUpSync({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
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
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
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