Extracted some classes and refactored for clarity

This commit is contained in:
Daz DeBoer 2022-06-22 16:35:55 -06:00
parent 7f46dbd76f
commit 884bca012f
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D
7 changed files with 95 additions and 91 deletions

27
src/build-results.ts Normal file
View file

@ -0,0 +1,27 @@
import * as fs from 'fs'
import * as path from 'path'
export interface BuildResult {
get rootProjectName(): string
get rootProjectDir(): string
get requestedTasks(): string
get gradleVersion(): string
get gradleHomeDir(): string
get buildFailed(): boolean
get buildScanUri(): string
get buildScanFailed(): boolean
}
export function loadBuildResults(): BuildResult[] {
const buildResultsDir = path.resolve(process.env['RUNNER_TEMP']!, '.build-results')
if (!fs.existsSync(buildResultsDir)) {
return []
}
return fs.readdirSync(buildResultsDir).map(file => {
// Every file in the .build-results dir should be a BuildResults JSON
const filePath = path.join(buildResultsDir, file)
const content = fs.readFileSync(filePath, 'utf8')
return JSON.parse(content) as BuildResult
})
}