Skip to content

Commit

Permalink
fix(errors): improve message when version validation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous committed Oct 24, 2023
1 parent 6fd3bc8 commit 1fad02a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
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

0 comments on commit 1fad02a

Please sign in to comment.