Skip to content

Commit

Permalink
Merge pull request #3 from hpi-schul-cloud/error-on-empty-license-list
Browse files Browse the repository at this point in the history
return error if merged list is empty
  • Loading branch information
Loki-Afro authored Mar 5, 2025
2 parents 5e510fb + b0598f7 commit 86d740d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions dist/index.js

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

7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export const run = async () => {

core.info("=== 2. Generating merged SBOM ===");
const mergedSbom = new MergedSbom(sboms);
if (mergedSbom.isEmpty()) {
throw new Error("Merged SBOM is empty");
}
core.setOutput("json", mergedSbom.toString());
} catch (error) {
const message = "message" in error ? error.nessage : error;
core.error(message);
core.error(error);
process.exit(1);
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/MergedSbom.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default class MergedSbom {
return JSON.stringify(licenseList, null, 2);
}

isEmpty() {
return Object.keys(this.mergedSbom).length === 0;
}

getLicenseList() {
const licenseNames = this.getLicenseNames();
licenseNames.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
Expand Down

0 comments on commit 86d740d

Please sign in to comment.