2019-09-21 10:01:53 -04:00
|
|
|
import * as exec from "@actions/exec";
|
|
|
|
|
|
|
|
|
|
|
|
export async function execute(executable: string, root: string, argv: string[]): Promise<BuildResult> {
|
|
|
|
|
|
|
|
let publishing = false;
|
2019-09-23 06:11:18 -04:00
|
|
|
let buildScanUrl: string | undefined;
|
2019-09-21 10:01:53 -04:00
|
|
|
|
2019-09-23 06:11:18 -04:00
|
|
|
const status: number = await exec.exec(executable, argv, {
|
2019-09-21 10:01:53 -04:00
|
|
|
cwd: root,
|
2019-09-23 06:11:18 -04:00
|
|
|
ignoreReturnCode: true,
|
2019-09-21 10:01:53 -04:00
|
|
|
listeners: {
|
|
|
|
stdline: (line: string) => {
|
|
|
|
if (line.startsWith("Publishing build scan...")) {
|
|
|
|
publishing = true;
|
|
|
|
}
|
|
|
|
if (publishing && line.length == 0) {
|
|
|
|
publishing = false
|
|
|
|
}
|
|
|
|
if (publishing && line.startsWith("http")) {
|
2019-09-23 06:11:18 -04:00
|
|
|
buildScanUrl = line.trim();
|
2019-09-21 10:01:53 -04:00
|
|
|
publishing = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-23 06:11:18 -04:00
|
|
|
return new BuildResultImpl(status, buildScanUrl);
|
2019-09-21 10:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface BuildResult {
|
2019-09-23 06:11:18 -04:00
|
|
|
readonly status: number
|
|
|
|
readonly buildScanUrl?: string
|
2019-09-21 10:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
class BuildResultImpl implements BuildResult {
|
2019-09-23 06:11:18 -04:00
|
|
|
constructor(
|
|
|
|
readonly status: number,
|
|
|
|
readonly buildScanUrl?: string
|
|
|
|
) {
|
2019-09-21 10:01:53 -04:00
|
|
|
}
|
|
|
|
}
|