Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace read-pkg with read-package-json-fast #745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/get-pkg.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import path from "path";
import { readPackage } from "read-pkg";
import rpj from "read-package-json-fast";
import AggregateError from "aggregate-error";
import getError from "./get-error.js";

export default async function ({ pkgRoot }, { cwd }) {
try {
const pkg = await readPackage({ cwd: pkgRoot ? path.resolve(cwd, String(pkgRoot)) : cwd });
const normalizedCwd = pkgRoot ? path.resolve(cwd, String(pkgRoot)) : cwd;
const pathToPkg = path.join(normalizedCwd, "package.json");
const pkg = await rpj(pathToPkg);

if (!pkg.name) {
throw getError("ENOPKGNAME");
Expand Down
73 changes: 67 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"normalize-url": "^8.0.0",
"npm": "^10.0.0",
"rc": "^1.2.8",
"read-pkg": "^9.0.0",
"read-package-json-fast": "^3.0.2",
"registry-auth-token": "^5.0.0",
"semver": "^7.1.2",
"tempy": "^3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion test/get-pkg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ test("Throw error if package.json is malformed", async (t) => {
errors: [error],
} = await t.throwsAsync(getPkg({}, { cwd }));

t.is(error.name, "JSONError");
t.is(error.name, "JSONParseError");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could technically be seen as a breaking change1. The underlying libraries just use different error classes.

Footnotes

  1. considering this is a semantic-release library, I'm guessing the change is breaking?

});