Skip to content

Commit

Permalink
Rename .package to .packageJson
Browse files Browse the repository at this point in the history
Since `package` is a reserved keyword, it meant that the result could previously not be easily destructured.

Fixes #11
  • Loading branch information
sindresorhus committed Sep 27, 2019
1 parent 9ecaa3e commit 8140c73
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ declare namespace readPkgUp {
type NormalizedPackageJson = readPkg.NormalizedPackageJson;

interface ReadResult {
package: PackageJson;
packageJson: PackageJson;
path: string;
}

interface NormalizedReadResult {
package: NormalizedPackageJson;
packageJson: NormalizedPackageJson;
path: string;
}
}
Expand All @@ -45,7 +45,7 @@ declare const readPkgUp: {
(async () => {
console.log(await readPkgUp());
// {
// package: {
// packageJson: {
// name: 'awesome-package',
// version: '1.0.0',
// …
Expand All @@ -69,7 +69,7 @@ declare const readPkgUp: {
console.log(readPkgUp.sync());
// {
// package: {
// packageJson: {
// name: 'awesome-package',
// version: '1.0.0',
// …
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = async options => {
}

return {
package: await readPkg({...options, cwd: path.dirname(filePath)}),
packageJson: await readPkg({...options, cwd: path.dirname(filePath)}),
path: filePath
};
};
Expand All @@ -24,7 +24,7 @@ module.exports.sync = options => {
}

return {
package: readPkg.sync({...options, cwd: path.dirname(filePath)}),
packageJson: readPkg.sync({...options, cwd: path.dirname(filePath)}),
path: filePath
};
};
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const readPkgUp = require('read-pkg-up');
console.log(await readPkgUp());
/*
{
package: {
packageJson: {
name: 'awesome-package',
version: '1.0.0',
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const packagePath = path.resolve('.', 'package.json');

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

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

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

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

0 comments on commit 8140c73

Please sign in to comment.