Skip to content

Commit 6cc4d8d

Browse files
committed
Add Result class
1 parent d80b955 commit 6cc4d8d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

helpers/result.mjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export class Result {
2+
/**
3+
* For storing and sharing results.
4+
*
5+
* @param {string} repoOwner - The owner of the repository.
6+
* @param {string} repoName - The name of the repository.
7+
*/
8+
constructor (repoOwner, repoName) {
9+
if (!repoOwner) {
10+
this.log('repoOwner must be provided', 'error')
11+
throw new Error('repoOwner must be provided')
12+
}
13+
if (!repoName) {
14+
this.log('repoName must be provided', 'error')
15+
throw new Error('repoName must be provided')
16+
}
17+
this.repoOwner = repoOwner
18+
this.repoName = repoName
19+
this.builtByGovernment = false
20+
this.isPrototype = false
21+
this.updatedAt = ''
22+
this.createdAt = ''
23+
this.directDependencies = []
24+
this.indirectDependencies = []
25+
26+
// Non returned values
27+
this.latestCommitSHA = ''
28+
this.repoTree = []
29+
}
30+
31+
getResult () {
32+
return {
33+
repoOwner: this.repoOwner,
34+
repoName: this.repoName,
35+
builtByGovernment: this.builtByGovernment,
36+
updatedAt: this.updatedAt,
37+
createdAt: this.createdAt,
38+
directDependencies: this.directDependencies,
39+
isPrototype: this.isPrototype,
40+
isIndirect: this.directDependencies.length === 0
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)