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
8 changes: 7 additions & 1 deletion src/outputStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ export class OutputStyleManager {
const outputStyle = this.outputStyles.find(
(style) => style.name === name,
);
assert(outputStyle, `Output style ${name} not found`);
if (!outputStyle) {
const availableStyles = this.outputStyles.map((style) => style.name);
console.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.warn 在 ink 渲染模式下不太可靠,感觉还是得显式报错,但不是以 crash 的形式。我想想怎么 fix 。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我一开始是想显示报错的,提问的时候应该用助手回答的方式,不过写了好一会没写好,就用了这种简单一点的

`\nOutput style "${name}" not found, will use default style. Available styles: ${availableStyles.join(', ')}\n`,
);
return defaultOutputStyle;
}
return outputStyle;
} else {
return defaultOutputStyle;
Expand Down
Loading