Skip to content

Commit

Permalink
Merge pull request #4581 from Shopify/fd-delete-warning
Browse files Browse the repository at this point in the history
[Theme] Avoid process exit when failing to delete a file from the remote theme
  • Loading branch information
frandiox authored Oct 7, 2024
2 parents a825c91 + df7b178 commit dfa019f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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

0 comments on commit dfa019f

Please sign in to comment.