Skip to content

capture error on command failure #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
capture error on command failure
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jan 9, 2022
commit fc9218c348b5070a2f8f73ffecd05664967b3692
1 change: 0 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ cd web-app
yarn build
cd ..

# For Windows build: switch the next 2 lines
echo "Bundling webapp..."
if [[ "$OSTYPE" == "msys" ]]; then
# linux subsystem on windows selected
Expand Down
6 changes: 5 additions & 1 deletion src/services/hooks/utils/runCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ const runCommands = async (commands: string[] = []): Promise<void> => {
title: command,
description: 'Running process...',
}
logger(`Command: ${command}`)
send({ type: 'COMMAND_START', payload: { process: { ...process, status: 'RUNNING' } } })
let result: { stdout: string; stderr: string }
try {
result = await exec({ command })
logger(`Command output: ${JSON.stringify(result)}`)
if (result.stderr) {
throw new Error(result.stderr)
}
logger(`Command output: ${result.stdout}`)
} catch (error: any) {
logger(`Command failed: ${error.message}`)
send({ type: '', payload: { process: { ...process, status: 'FAIL' } } })
Expand Down