diff --git a/src/lib/commands.ts b/src/lib/commands.ts index cf533c0..e384407 100644 --- a/src/lib/commands.ts +++ b/src/lib/commands.ts @@ -26,26 +26,22 @@ const dockerEnv = { } const up = async (stackName: string, cwd: string) => - ( - await exec( - `nitric up --ci --stack ${stackName}`, - undefined, - cwd, - false, - dockerEnv - ) - ).stdout + await exec( + `nitric up --ci --stack ${stackName}`, + undefined, + cwd, + false, + dockerEnv + ) const down = async (stackName: string, cwd: string) => - ( - await exec( - `nitric down --ci --stack ${stackName}`, - undefined, - cwd, - false, - dockerEnv - ) - ).stdout + await exec( + `nitric down --ci --stack ${stackName}`, + undefined, + cwd, + false, + dockerEnv + ) export const commands = { up, diff --git a/src/main.ts b/src/main.ts index c611456..ee87b10 100644 --- a/src/main.ts +++ b/src/main.ts @@ -108,10 +108,20 @@ export async function run() { // run command if exists if (command && stackName) { core.info(`Running command ${command}`) - const output = await commands[command as keyof typeof commands]( + const { + stdout: output, + success, + stderr + } = await commands[command as keyof typeof commands]( stackName, workingDirectory ) + + if (!success) { + core.error(`Failed running command ${command}`) + throw new Error(stderr) + } + core.info(`Done running command ${command}`) core.setOutput('output', output)