Skip to content

Commit

Permalink
Merge pull request #5230 from Shopify/01-17-don_t_start_the_dev_sessi…
Browse files Browse the repository at this point in the history
…on_if_there_are_build_errors

Don't start the dev session if there are build errors
  • Loading branch information
isaacroldan authored Jan 21, 2025
2 parents e27d778 + fe089c6 commit 28cfaea
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/app/src/cli/services/dev/processes/dev-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ export const pushUpdatesForDevSession: DevProcessFunction<DevSessionOptions> = a
)
})
.onStart(async (event) => {
const buildErrors = event.extensionEvents.filter((eve) => eve.buildResult?.status === 'error')
if (buildErrors.length) {
const errors = buildErrors.map((error) => ({
error: 'Build error. Please review your code and try again.',
prefix: error.extension.handle,
}))
await printMultipleErrors(errors, processOptions.stdout)
throw new AbortError('Dev session aborted, build errors detected in extensions.')
}
const result = await bundleExtensionsAndUpload({...processOptions, app: event.app})
await handleDevSessionResult(result, {...processOptions, app: event.app})
})
Expand Down Expand Up @@ -335,6 +344,16 @@ async function printError(message: string, stdout: Writable, prefix?: string) {
await printLogMessage(outputContent`${content}`.value, stdout, prefix)
}

async function printMultipleErrors(errors: {error: string; prefix: string}[], stdout: Writable) {
const header = outputToken.errorText(`❌ Error`)
await printLogMessage(outputContent`${header}`.value, stdout, 'dev-session')
const messages = errors.map((error) => {
const content = outputToken.errorText(`└ ${error.error}`)
return printLogMessage(outputContent`${content}`.value, stdout, error.prefix)
})
await Promise.all(messages)
}

async function printSuccess(message: string, stdout: Writable) {
await printLogMessage(outputContent`${outputToken.green(message)}`.value, stdout)
}
Expand Down

0 comments on commit 28cfaea

Please sign in to comment.