For reference, see the Automated Deployment guidance documentation. In it, we're instructed to run
node -e "require('./server/src/middlewares/dev/apps/app-download.js').zipApp('0', 'app.zip', 'my_client_id');"
to download our zip.
This works well enough in the ideal case. However, when zipApp fails we are left with nothing but error messages in stderr to indicate the failure. It would be helpful for our automated systems if zipApp would either: (1) exit with a non-zero exit code (2) return a non-zero number or (3), throw an error we can catch via try/catch.
My preference would be on #1 so we can easily check the error code in shells like cmd/PowerShell/bash.
I have a workaround in PowerShell that's rather ugly (↴). If a non-zero exit-code were returned I could simply call the function as described in the docs and the build would fail appropriately.
$ErrorActionPreference = $Stop
$PSNativeCommandUseErrorActionPreference = $true
if (Test-Path err.txt) { Remove-Item err.txt -Force }
node -e "require('./server/src/middlewares/dev/apps/app-download.js').zipApp('0', '$AppZip', '$ClientId');" 2>err.txt
$err = Get-Content err.txt -Raw
if ($err.Length -gt 0) {
Write-Host "ZipApp failed with an unhandled exception ↴"
throw $err
}
If others have found cleaner solutions, I would love to hear them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.