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

fix(errors): improve message when version validation fails #161

Merged
merged 1 commit into from
Oct 24, 2023
Merged
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 dist/main.js

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

4 changes: 2 additions & 2 deletions dist/main.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/__tests__/read-manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ describe("readManifest", () => {
const result = subject.readManifest(directory);

await expect(result).rejects.toThrow(errors.InvalidPackageVersionError);
await expect(result).rejects.toThrow(/42/iu);
});

it("should error if publishConfig is invalid", async () => {
Expand Down
4 changes: 3 additions & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export class InvalidPackageNameError extends TypeError {

export class InvalidPackageVersionError extends TypeError {
public constructor(value: unknown) {
super(`Package version must be a string, got "${String(value)}"`);
super(
`Package version must be a valid semantic version, got "${String(value)}"`
);
this.name = "InvalidPackageVersionError";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/read-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export async function readManifest(
}

if (typeof version !== "string") {
throw new errors.InvalidPackageVersionError(version);
throw new errors.InvalidPackageVersionError(manifestJson["version"]);
}

if (
Expand Down