Skip to content

Commit

Permalink
Retry with --debug on error
Browse files Browse the repository at this point in the history
  • Loading branch information
jhuleatt committed Sep 9, 2020
1 parent 29b1863 commit 6245af4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/action.min.js

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ async function execWithCredentials(
firebase,
args: string[],
projectId,
gacFilename
gacFilename,
debug: boolean = false
) {
let deployOutputBuf: Buffer[] = [];
try {
Expand All @@ -59,8 +60,9 @@ async function execWithCredentials(
[
...args,
...(projectId ? ["--project", projectId] : []),
"--json", // keep this option in so that we can easily parse the output
// "--debug", // uncomment this for better error output],
debug
? "--debug" // gives a more thorough error message
: "--json", // allows us to easily parse the output
],
{
listeners: {
Expand All @@ -77,7 +79,15 @@ async function execWithCredentials(
} catch (e) {
console.log(Buffer.concat(deployOutputBuf).toString("utf-8"));
console.log(e.message);
throw e;

if (debug === false) {
console.log(
"Retrying deploy with the --debug flag for better error output"
);
return execWithCredentials(firebase, args, projectId, gacFilename, true);
} else {
throw e;
}
}

return Buffer.concat(deployOutputBuf).toString("utf-8"); // output from the CLI
Expand All @@ -92,7 +102,7 @@ export async function deploy(

const deploymentText = await execWithCredentials(
firebase,
["hosting:channel:deploy", channelId],
["hosting:channel:deploy", channelId, "--expires", "7d"],
projectId,
gacFilename
);
Expand Down

0 comments on commit 6245af4

Please sign in to comment.