mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-02 13:11:05 -05:00
063fc6a872
This avoids excessive line-feeds when reformatting code to 80 char lines.
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import * as exec from '@actions/exec'
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
import {writeInitScript} from './build-scan-capture'
|
|
|
|
export async function execute(executable: string, root: string, args: string[]): Promise<BuildResult> {
|
|
let buildScanUrl: string | undefined
|
|
|
|
// TODO: instead of running with no-daemon, run `--stop` in post action.
|
|
args.push('--no-daemon')
|
|
|
|
const initScript = writeInitScript()
|
|
args.push('--init-script')
|
|
args.push(initScript)
|
|
|
|
const buildScanFile = path.resolve(root, 'gradle-build-scan.txt')
|
|
if (fs.existsSync(buildScanFile)) {
|
|
fs.unlinkSync(buildScanFile)
|
|
}
|
|
|
|
const status: number = await exec.exec(executable, args, {
|
|
cwd: root,
|
|
ignoreReturnCode: true
|
|
})
|
|
|
|
if (fs.existsSync(buildScanFile)) {
|
|
buildScanUrl = fs.readFileSync(buildScanFile, 'utf-8')
|
|
}
|
|
|
|
return new BuildResultImpl(status, buildScanUrl)
|
|
}
|
|
|
|
export interface BuildResult {
|
|
readonly status: number
|
|
readonly buildScanUrl?: string
|
|
}
|
|
|
|
class BuildResultImpl implements BuildResult {
|
|
constructor(readonly status: number, readonly buildScanUrl?: string) {}
|
|
}
|