Skip to content

Commit

Permalink
refactor: undefined to null
Browse files Browse the repository at this point in the history
Replace undefined with null in argument for makePackageReference function since it is an intentionally missing value
  • Loading branch information
ComradeVanti committed Sep 29, 2024
1 parent 2d856be commit 474464a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/domain/package-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ export function splitPackageReference(
*/
export function makePackageReference(
name: string,
version?: string
version: string | null
): PackageReference {
assertZod(name, DomainName);
if (version === null) return name;
assert(
version === undefined || isVersionReference(version),
`"${version}" is valid version-reference`
isVersionReference(version),
`"${version}" is not a valid version reference.`
);
return version !== undefined ? `${name}@${version}` : name;
return `${name}@${version}`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/unit/domain/package-reference.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("package-reference", () => {
describe("split", () => {
function shouldSplitCorrectly(name: string, version?: string) {
const [actualName, actualVersion] = splitPackageReference(
makePackageReference(name, version)
makePackageReference(name, version ?? null)
);
expect(actualName).toEqual(name);
expect(actualVersion).toEqual(version ?? null);
Expand Down

0 comments on commit 474464a

Please sign in to comment.