Skip to content

Commit d393005

Browse files
fix: pin figlet to 1.8.1 and harden banner against load failures (#48)
1 parent 16ea2ce commit d393005

3 files changed

Lines changed: 28 additions & 19 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"axios": "^1.9.0",
2929
"chalk": "^4.1.2",
3030
"commander": "^13.1.0",
31-
"figlet": "^1.7.0",
31+
"figlet": "1.8.1",
3232
"gradient-string": "^2.0.2",
3333
"inquirer": "^12.6.1",
3434
"jsonwebtoken": "^9.0.2",

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/banner.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { logger } from "@utils/logger";
21
import gradient from "gradient-string";
32
import chalk from "chalk";
4-
const figlet = require("figlet");
53

64
import { getVersion } from "./version";
75

8-
export const showBanner = async (): Promise<void> => {
6+
const renderFigletBanner = (): Promise<string> => {
7+
const figlet = require("figlet");
8+
99
return new Promise((resolve, reject) => {
1010
figlet.text(
1111
"STALLION",
@@ -15,23 +15,32 @@ export const showBanner = async (): Promise<void> => {
1515
verticalLayout: "default",
1616
},
1717
(err: any, data: any) => {
18-
if (err) {
19-
reject("Something went wrong...");
18+
if (err || !data) {
19+
reject(err ?? new Error("figlet returned no output"));
2020
return;
2121
}
22-
// Apply retro gradient to the banner
23-
const gradientBanner = gradient.retro.multiline(data || "");
24-
console.log(gradientBanner);
25-
console.log(
26-
"\n" +
27-
chalk.whiteBright(
28-
`⚡ Welcome to the Stallion CLI ${chalk.bold(
29-
chalk.greenBright(`v${getVersion()}`)
30-
)} ⚡ \n`
31-
)
32-
);
33-
resolve();
22+
resolve(data);
3423
}
3524
);
3625
});
3726
};
27+
28+
export const showBanner = async (): Promise<void> => {
29+
let banner = "STALLION";
30+
31+
try {
32+
banner = await renderFigletBanner();
33+
} catch {
34+
// Decorative only — fall back to the plain wordmark.
35+
}
36+
37+
console.log(gradient.retro.multiline(banner));
38+
console.log(
39+
"\n" +
40+
chalk.whiteBright(
41+
`⚡ Welcome to the Stallion CLI ${chalk.bold(
42+
chalk.greenBright(`v${getVersion()}`)
43+
)} ⚡ \n`
44+
)
45+
);
46+
};

0 commit comments

Comments
 (0)