Skip to content

Commit

Permalink
Catch and print docker build errors (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcroote authored Oct 19, 2022
1 parent f6becd5 commit d23503a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/fresh-vans-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@api3/airnode-admin': minor
'@api3/airnode-deployer': minor
'@api3/airnode-node': minor
---

Catch and print docker build errors
15 changes: 14 additions & 1 deletion docker/scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@ import { logger } from '@api3/airnode-utilities';

export const runCommand = (command: string, options?: ExecSyncOptions) => {
logger.log(`Running command: '${command}'${options ? ` with options ${JSON.stringify(options)}` : ''}`);
return execSync(command, options);
try {
return execSync(command, options);
} catch (e) {
// Thrown Error object contains the entire result from child_process.spawnSync()
const err = e as any;
throw new Error(
[
``,
`Command failed with non-zero status code: ${err.status}`,
`Stderr: ${err.stderr.toString().trim()}.`,
`Stdout: ${err.stdout.toString().trim()}.`,
].join('\n')
);
}
};

// Taken from https://github.com/sindresorhus/is-docker
Expand Down

0 comments on commit d23503a

Please sign in to comment.