Skip to content

Commit

Permalink
Rename package from pkg-up to package-up
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 4, 2023
1 parent b902cd5 commit 4a4d1db
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
12 changes: 6 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Find the closest `package.json` file.
// └── example.js
// example.js
import {pkgUp} from 'pkg-up';
import {packageUp} from 'package-up';
console.log(await pkgUp());
console.log(await packageUp());
//=> '/Users/sindresorhus/foo/package.json'
```
*/
export function pkgUp(options?: Options): Promise<string | undefined>;
export function packageUp(options?: Options): Promise<string | undefined>;

/**
Synchronously find the closest `package.json` file.
Expand All @@ -49,11 +49,11 @@ Synchronously find the closest `package.json` file.
// └── example.js
// example.js
import {pkgUpSync} from 'pkg-up';
import {packageUpSync} from 'package-up';
console.log(pkgUpSync());
console.log(packageUpSync());
//=> '/Users/sindresorhus/foo/package.json'
```
*/
export function pkgUpSync(options?: Options): string | undefined;
export function packageUpSync(options?: Options): string | undefined;

4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import process from 'node:process';
import {findUp, findUpSync} from 'find-up-simple';

export async function pkgUp({cwd = process.cwd()} = {}) {
export async function packageUp({cwd = process.cwd()} = {}) {
return findUp('package.json', {cwd});
}

export function pkgUpSync({cwd = process.cwd()} = {}) {
export function packageUpSync({cwd = process.cwd()} = {}) {
return findUpSync('package.json', {cwd});
}
10 changes: 5 additions & 5 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expectType} from 'tsd';
import {pkgUp, pkgUpSync} from './index.js';
import {packageUp, packageUpSync} from './index.js';

expectType<Promise<string | undefined>>(pkgUp());
expectType<Promise<string | undefined>>(pkgUp({cwd: '.'}));
expectType<string | undefined>(pkgUpSync());
expectType<string | undefined>(pkgUpSync({cwd: '.'}));
expectType<Promise<string | undefined>>(packageUp());
expectType<Promise<string | undefined>>(packageUp({cwd: '.'}));
expectType<string | undefined>(packageUpSync());
expectType<string | undefined>(packageUpSync({cwd: '.'}));
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "pkg-up",
"name": "package-up",
"version": "4.0.0",
"description": "Find the closest package.json file",
"license": "MIT",
"repository": "sindresorhus/pkg-up",
"repository": "sindresorhus/package-up",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
Expand Down
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# pkg-up
# package-up

> Find the closest package.json file
## Install

```sh
npm install pkg-up
npm install package-up
```

## Usage
Expand All @@ -23,19 +23,19 @@ npm install pkg-up

```js
// example.js
import {pkgUp} from 'pkg-up';
import {packageUp} from 'package-up';

console.log(await pkgUp());
console.log(await packageUp());
//=> '/Users/sindresorhus/foo/package.json'
```

## API

### pkgUp(options?)
### packageUp(options?)

Returns a `Promise<string>` for the file path, or `Promise<undefined>` if it could not be found.

### pkgUpSync(options?)
### packageUpSync(options?)

Returns the file path, or `undefined` if it could not be found.

Expand Down
12 changes: 6 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import test from 'ava';
import {pkgUp, pkgUpSync} from './index.js';
import {packageUp, packageUpSync} from './index.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const cwd = path.join(__dirname, 'fixture');
const pkgPath = path.join(__dirname, 'package.json');
const packagePath = path.join(__dirname, 'package.json');

test('async', async t => {
t.is(await pkgUp({cwd}), pkgPath);
t.is(path.dirname(await pkgUp()), __dirname);
t.is(await packageUp({cwd}), packagePath);
t.is(path.dirname(await packageUp()), __dirname);
});

test('sync', t => {
t.is(pkgUpSync({cwd}), pkgPath);
t.is(path.dirname(pkgUpSync()), __dirname);
t.is(packageUpSync({cwd}), packagePath);
t.is(path.dirname(packageUpSync()), __dirname);
});

0 comments on commit 4a4d1db

Please sign in to comment.