Skip to content

Commit

Permalink
Fix bug in new --format ts flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Dec 3, 2024
1 parent 1aa7c6b commit f117a36
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/utils/src/artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export function exportArtifact(artifact: Artifact, targetFile: string, format: '

export function formatArtifact(artifact: Artifact, format: 'json' | 'ts'): string {
if (format === 'ts') {
return `export default ${stringifyAsTs(artifact)} as const;\n`;
// We remove any undefined values to make the artifact serializable using stringifyAsTs
const normalisedArtifact = JSON.parse(JSON.stringify(artifact));
return `export default ${stringifyAsTs(normalisedArtifact)} as const;\n`;
}

return JSON.stringify(artifact, null, 2);
Expand Down

0 comments on commit f117a36

Please sign in to comment.