Skip to content

Commit

Permalink
Add Result class
Browse files Browse the repository at this point in the history
  • Loading branch information
domoscargin committed Jan 14, 2025
1 parent 3d87bbb commit efbb8ae
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions helpers/result.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export class Result {
/**
* For storing and sharing results.
*
* @param {string} repoOwner - The owner of the repository.
* @param {string} repoName - The name of the repository.
*/
constructor (repoOwner, repoName) {
if (!repoOwner) {
this.log('repoOwner must be provided', 'error')
throw new Error('repoOwner must be provided')
}
if (!repoName) {
this.log('repoName must be provided', 'error')
throw new Error('repoName must be provided')
}
this.repoOwner = repoOwner
this.repoName = repoName
this.builtByGovernment = false
this.isPrototype = false
this.updatedAt = ''
this.createdAt = ''
this.directDependencies = []
this.indirectDependencies = []

// Non returned values
this.latestCommitSHA = ''
this.repoTree = []
}

getResult () {
return {
repoOwner: this.repoOwner,
repoName: this.repoName,
builtByGovernment: this.builtByGovernment,
updatedAt: this.updatedAt,
createdAt: this.createdAt,
directDependencies: this.directDependencies,
isPrototype: this.isPrototype,
isIndirect: this.directDependencies.length === 0,
indirectDependencies: this.indirectDependencies
}
}
}

0 comments on commit efbb8ae

Please sign in to comment.