Skip to content

Commit 63951bd

Browse files
committed
fix: another typo
1 parent 7ed3344 commit 63951bd

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/cli/index.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const pkg = require("../../package.json");
2222

2323
function printWelcomeMessage(argv?: string[]) {
2424
const args = argv?.slice(2) || [];
25-
const showVersion = args.includes("--version") || args.includes("-v") || args.includes("ping");
25+
const showVersion = args.includes("--version") || args.includes("-v") || args.includes("--ping");
2626
const hideMessage = process.env.SWA_CLI_INTERNAL_COMMAND || showVersion;
2727

2828
if (!hideMessage) {
@@ -68,17 +68,18 @@ export async function run(argv?: string[]) {
6868
.option("-cn, --config-name <name>", "name of the configuration to use", undefined)
6969
.option("-g, --print-config", "print all resolved options", false)
7070
.action(async (_options: SWACLIConfig, command: Command) => {
71+
if ((_options as any).ping) {
72+
try {
73+
require("child_process").execSync("npx command-line-pong", { stdio: ["inherit", "inherit", "ignore"] });
74+
} catch (e) {
75+
console.log("pong!");
76+
}
77+
return;
78+
}
79+
7180
const options = await configureOptions(undefined, command.optsWithGlobals(), command, "init");
7281
swaMagic(options);
7382
})
74-
.command("ping")
75-
.action(() => {
76-
try {
77-
require("child_process").execSync("npx command-line-pong", { stdio: ["inherit", "inherit", "ignore"] });
78-
} catch (e) {
79-
console.log("pong!");
80-
}
81-
})
8283
.addHelpText(
8384
"after",
8485
`
@@ -98,6 +99,7 @@ export async function run(argv?: string[]) {
9899
registerDocs(program);
99100

100101
program.showHelpAfterError();
102+
program.addOption(new Option("--ping").hideHelp());
101103

102104
await program.parseAsync(argv);
103105
}

0 commit comments

Comments
 (0)