Skip to content
Open
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
18 changes: 7 additions & 11 deletions packages/theme/src/cli/utilities/asset-checksum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,23 @@ function md5(content: string | Buffer) {
* as these are not needed for theme comparison.
*/
export function rejectGeneratedStaticAssets(themeChecksums: Checksum[]) {
const liquidAssetKeys = new Set(
themeChecksums
.filter(({key}) => key.startsWith('assets/') && key.endsWith('.liquid'))
.map(({key}) => key),
)

return themeChecksums.filter(({key}) => {
const isStaticAsset = key.startsWith('assets/')

if (isStaticAsset) {
return !hasLiquidSource(themeChecksums, key)
return !liquidAssetKeys.has(`${key}.liquid`)
}

return true
})
}

/**
* Checks if a given key has a corresponding liquid source in the provided checksums.
* @param checksums - The array of checksums to search through.
* @param key - The key to check for a liquid source.
* @returns True if a liquid source exists for the given key, false otherwise.
*/
function hasLiquidSource(checksums: Checksum[], key: string) {
return checksums.some((checksum) => checksum.key === `${key}.liquid`)
}

function isSettingsData(path: string) {
return path.endsWith('/settings_data.json')
}
Loading