Skip to content
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

[Theme] Avoid process exit when failing to delete a file from the remote theme #4581

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/rotten-worms-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/theme': patch
---

Avoid process exit when failing to delete a file from the remote theme.
12 changes: 8 additions & 4 deletions packages/theme/src/cli/utilities/theme-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {renderTasksToStdErr} from './theme-ui.js'
import {AdminSession} from '@shopify/cli-kit/node/session'
import {Result, Checksum, Theme, ThemeFileSystem} from '@shopify/cli-kit/node/themes/types'
import {AssetParams, bulkUploadThemeAssets, deleteThemeAsset} from '@shopify/cli-kit/node/themes/api'
import {renderWarning, Task} from '@shopify/cli-kit/node/ui'
import {renderError, renderWarning, Task} from '@shopify/cli-kit/node/ui'
import {outputDebug, outputInfo, outputNewline, outputWarn} from '@shopify/cli-kit/node/output'

interface UploadOptions {
Expand Down Expand Up @@ -127,9 +127,13 @@ function buildDeleteJob(
const progress = {current: 0, total: orderedFiles.length}
const promise = Promise.all(
orderedFiles.map((file) =>
deleteThemeAsset(theme.id, file.key, session).then(() => {
progress.current++
}),
deleteThemeAsset(theme.id, file.key, session)
.catch((error) => {
renderError({headline: `Failed to delete file "${file.key}" from remote theme.`, body: error.message})
})
.finally(() => {
progress.current++
}),
),
).then(() => {
progress.current = progress.total
Expand Down
Loading