Skip to content

Commit

Permalink
Merge pull request #4475 from Shopify/jm/fixpull
Browse files Browse the repository at this point in the history
[Themes] Account for empty assets when calculating theme asset size
  • Loading branch information
jamesmengo committed Sep 19, 2024
2 parents 5cf4928 + 3756ce8 commit d71bca9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-sloths-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli-kit': patch
---

Fix a bug when building empty theme assets
6 changes: 3 additions & 3 deletions packages/cli-kit/src/public/node/themes/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ interface RemoteThemeResponse {
interface RemoteAssetResponse {
key: string
checksum: string
attachment: string
attachment: string | undefined
// value is an empty string ('') when the file is empty
value: string
}

Expand Down Expand Up @@ -52,8 +53,7 @@ export function buildThemeAsset(asset?: RemoteAssetResponse): ThemeAsset | undef

const {key, checksum, attachment, value} = asset
// Note: for attachments, this is the size of the base64 string, not the real length of the file
const stats = {size: (value || attachment).length, mtime: Date.now()}

const stats = {size: (value || attachment || '').length, mtime: Date.now()}
return {key, checksum, attachment, value, stats}
}

Expand Down

0 comments on commit d71bca9

Please sign in to comment.