Skip to content

Commit 8140c73

Browse files
committedSep 27, 2019
Rename .package to .packageJson
Since `package` is a reserved keyword, it meant that the result could previously not be easily destructured. Fixes #11
1 parent 9ecaa3e commit 8140c73

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed
 

‎index.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ declare namespace readPkgUp {
2424
type NormalizedPackageJson = readPkg.NormalizedPackageJson;
2525

2626
interface ReadResult {
27-
package: PackageJson;
27+
packageJson: PackageJson;
2828
path: string;
2929
}
3030

3131
interface NormalizedReadResult {
32-
package: NormalizedPackageJson;
32+
packageJson: NormalizedPackageJson;
3333
path: string;
3434
}
3535
}
@@ -45,7 +45,7 @@ declare const readPkgUp: {
4545
(async () => {
4646
console.log(await readPkgUp());
4747
// {
48-
// package: {
48+
// packageJson: {
4949
// name: 'awesome-package',
5050
// version: '1.0.0',
5151
// …
@@ -69,7 +69,7 @@ declare const readPkgUp: {
6969
7070
console.log(readPkgUp.sync());
7171
// {
72-
// package: {
72+
// packageJson: {
7373
// name: 'awesome-package',
7474
// version: '1.0.0',
7575
// …

‎index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = async options => {
1111
}
1212

1313
return {
14-
package: await readPkg({...options, cwd: path.dirname(filePath)}),
14+
packageJson: await readPkg({...options, cwd: path.dirname(filePath)}),
1515
path: filePath
1616
};
1717
};
@@ -24,7 +24,7 @@ module.exports.sync = options => {
2424
}
2525

2626
return {
27-
package: readPkg.sync({...options, cwd: path.dirname(filePath)}),
27+
packageJson: readPkg.sync({...options, cwd: path.dirname(filePath)}),
2828
path: filePath
2929
};
3030
};

‎readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const readPkgUp = require('read-pkg-up');
2828
console.log(await readPkgUp());
2929
/*
3030
{
31-
package: {
31+
packageJson: {
3232
name: 'awesome-package',
3333
version: '1.0.0',
3434

‎test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ const packagePath = path.resolve('.', 'package.json');
77

88
test('async', async t => {
99
const result = await readPackageUp({cwd});
10-
t.is(result.package.name, 'read-pkg-up');
10+
t.is(result.packageJson.name, 'read-pkg-up');
1111
t.is(result.path, packagePath);
1212

1313
t.is(await readPackageUp({cwd: '/'}), undefined);
1414
});
1515

1616
test('sync', t => {
1717
const result = readPackageUp.sync({cwd});
18-
t.is(result.package.name, 'read-pkg-up');
18+
t.is(result.packageJson.name, 'read-pkg-up');
1919
t.is(result.path, packagePath);
2020

2121
t.is(readPackageUp.sync({cwd: '/'}), undefined);

0 commit comments

Comments
 (0)
Please sign in to comment.