|
1 | 1 | import { intro, log, outro } from "@clack/prompts"; |
2 | | -import { prepareDeploymentError } from "@trigger.dev/core/v3"; |
| 2 | +import { prepareDeploymentError, tryCatch } from "@trigger.dev/core/v3"; |
3 | 3 | import { InitializeDeploymentResponseBody } from "@trigger.dev/core/v3/schemas"; |
4 | 4 | import { Command, Option as CommandOption } from "commander"; |
5 | 5 | import { resolve } from "node:path"; |
@@ -238,25 +238,32 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) { |
238 | 238 |
|
239 | 239 | const { features } = resolvedConfig; |
240 | 240 |
|
241 | | - const buildManifest = await buildWorker({ |
242 | | - target: "deploy", |
243 | | - environment: options.env, |
244 | | - destination: destination.path, |
245 | | - resolvedConfig, |
246 | | - rewritePaths: true, |
247 | | - envVars: serverEnvVars.success ? serverEnvVars.data.variables : {}, |
248 | | - forcedExternals, |
249 | | - listener: { |
250 | | - onBundleStart() { |
251 | | - $buildSpinner.start("Building trigger code"); |
| 241 | + const [error, buildManifest] = await tryCatch( |
| 242 | + buildWorker({ |
| 243 | + target: "deploy", |
| 244 | + environment: options.env, |
| 245 | + destination: destination.path, |
| 246 | + resolvedConfig, |
| 247 | + rewritePaths: true, |
| 248 | + envVars: serverEnvVars.success ? serverEnvVars.data.variables : {}, |
| 249 | + forcedExternals, |
| 250 | + listener: { |
| 251 | + onBundleStart() { |
| 252 | + $buildSpinner.start("Building trigger code"); |
| 253 | + }, |
| 254 | + onBundleComplete(result) { |
| 255 | + $buildSpinner.stop("Successfully built code"); |
| 256 | + |
| 257 | + logger.debug("Bundle result", result); |
| 258 | + }, |
252 | 259 | }, |
253 | | - onBundleComplete(result) { |
254 | | - $buildSpinner.stop("Successfully built code"); |
| 260 | + }) |
| 261 | + ); |
255 | 262 |
|
256 | | - logger.debug("Bundle result", result); |
257 | | - }, |
258 | | - }, |
259 | | - }); |
| 263 | + if (error) { |
| 264 | + $buildSpinner.stop("Failed to build code"); |
| 265 | + throw error; |
| 266 | + } |
260 | 267 |
|
261 | 268 | logger.debug("Successfully built project to", destination.path); |
262 | 269 |
|
|
0 commit comments