This commit is contained in:
mitchellhamilton
2019-08-14 21:08:03 +10:00
parent fd6b063771
commit eafb4bf396
2 changed files with 23 additions and 17 deletions
+22 -16
View File
@@ -3,22 +3,27 @@ import { exec } from "@actions/exec";
import * as github from "@actions/github";
import fs from "fs-extra";
async function execWithOutput(command: string, args?: string[]) {
async function execWithOutput(
command: string,
args?: string[],
options?: { ignoreReturnCode?: boolean }
) {
let myOutput = "";
let myError = "";
const options = {
listeners: {
stdout: (data: Buffer) => {
myOutput += data.toString();
},
stderr: (data: Buffer) => {
myError += data.toString();
}
}
};
return {
code: await exec(command, args, options),
code: await exec(command, args, {
listeners: {
stdout: (data: Buffer) => {
myOutput += data.toString();
},
stderr: (data: Buffer) => {
myError += data.toString();
}
},
...options
}),
stdout: myOutput,
stderr: myError
};
@@ -99,10 +104,11 @@ async function execWithOutput(command: string, args?: string[]) {
return;
}
let { stderr } = await execWithOutput("git", [
"checkout",
"changeset-release"
]);
let { stderr } = await execWithOutput(
"git",
["checkout", "changeset-release"],
{ ignoreReturnCode: true }
);
let isCreatingChangesetReleaseBranch = !stderr
.toString()
.includes("Switched to a new branch 'changeset-release'");