Skip to content

Commit

Permalink
fix(cli): fallback to non-highlighted yaml if error occurs (#5560)
Browse files Browse the repository at this point in the history
This is a quickfix for #5442 to avoid Garden crashes on yaml highlighting.
The proper fix still needs to be implemented.
  • Loading branch information
vvagaytsev authored Dec 14, 2023
1 parent bd0460f commit 63eff7d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions core/src/util/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,21 @@ export function encodeYamlMulti(objects: object[]) {
}

export function highlightYaml(s: string) {
return highlight(s, {
language: "yaml",
theme: {
keyword: styles.accent.italic,
literal: styles.accent.italic,
string: styles.accent,
},
})
try {
return highlight(s, {
language: "yaml",
theme: {
keyword: styles.accent.italic,
literal: styles.accent.italic,
string: styles.accent,
},
})
} catch (err) {
// FIXME: this is a quickfix for https://github.com/garden-io/garden/issues/5442
// The issue needs to be fixed properly, by fixing Garden single app binary construction.
// Fallback to non-highlighted yaml if an error occurs.
return s
}
}

/**
Expand Down

0 comments on commit 63eff7d

Please sign in to comment.