fix: avoid duplicate cli banners
This commit is contained in:
parent
831de9ba8f
commit
0279f09459
2 changed files with 7 additions and 3 deletions
|
|
@ -92,3 +92,7 @@ export function emitCliBanner(version: string, options: BannerOptions = {}) {
|
||||||
process.stdout.write(`\n${line}\n\n`);
|
process.stdout.write(`\n${line}\n\n`);
|
||||||
bannerEmitted = true;
|
bannerEmitted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function hasEmittedCliBanner(): boolean {
|
||||||
|
return bannerEmitted;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ import { isRich, theme } from "../terminal/theme.js";
|
||||||
import { VERSION } from "../version.js";
|
import { VERSION } from "../version.js";
|
||||||
import {
|
import {
|
||||||
emitCliBanner,
|
emitCliBanner,
|
||||||
formatCliBannerArt,
|
|
||||||
formatCliBannerLine,
|
formatCliBannerLine,
|
||||||
|
hasEmittedCliBanner,
|
||||||
} from "./banner.js";
|
} from "./banner.js";
|
||||||
import { registerBrowserCli } from "./browser-cli.js";
|
import { registerBrowserCli } from "./browser-cli.js";
|
||||||
import { hasExplicitOptions } from "./command-options.js";
|
import { hasExplicitOptions } from "./command-options.js";
|
||||||
|
|
@ -106,10 +106,10 @@ export function buildProgram() {
|
||||||
}
|
}
|
||||||
|
|
||||||
program.addHelpText("beforeAll", () => {
|
program.addHelpText("beforeAll", () => {
|
||||||
|
if (hasEmittedCliBanner()) return "";
|
||||||
const rich = isRich();
|
const rich = isRich();
|
||||||
const art = formatCliBannerArt({ richTty: rich });
|
|
||||||
const line = formatCliBannerLine(PROGRAM_VERSION, { richTty: rich });
|
const line = formatCliBannerLine(PROGRAM_VERSION, { richTty: rich });
|
||||||
return `\n${art}\n${line}\n`;
|
return `\n${line}\n`;
|
||||||
});
|
});
|
||||||
|
|
||||||
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue