Skip to content

Commit

Permalink
Cope with missing version attribute on module
Browse files Browse the repository at this point in the history
  • Loading branch information
lalten committed Jan 26, 2024
1 parent e765a50 commit a430919
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 1 addition & 4 deletions e2e/fixtures/unversioned/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
module(
name = "unversioned",
version = "0.0.0",
)
module(name = "unversioned")
3 changes: 2 additions & 1 deletion src/domain/create-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ export class CreateEntryService {
): void {
if (moduleFile.version !== version) {
console.log(
"Archived MODULE.bazel version does not match release version. Creating a version patch."
`Archived MODULE.bazel version ${moduleFile.version} does not match release version ${version}.`,
"Creating a version patch.",
);
const patchFileName = "module_dot_bazel_version.patch";
const existingContent = moduleFile.content;
Expand Down
4 changes: 2 additions & 2 deletions src/domain/module-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class ModuleFile {

public get version(): string {
const regex = /module\([^)]*?version\s*=\s*"(.+?)"/s;
const version = this.moduleContent.match(regex)[1];
return version;
const match = this.moduleContent.match(regex);
return match ? match[1] : "(unversioned)";
}

public get content(): string {
Expand Down

0 comments on commit a430919

Please sign in to comment.