Skip to content

Commit 085e7cb

Browse files
committed
feat(preset-cli): Added the yes common option
1 parent a2d5bc3 commit 085e7cb

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

packages/plugin-prompts/src/components/prompts-builtin.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,8 +2722,10 @@ run(); `}
27222722
}
27232723
]}
27242724
returnType="Promise<boolean | symbol>">
2725-
{code`return new Promise<boolean | symbol>((response, reject) => {
2726-
const prompt = new ConfirmPrompt(config);
2725+
{code`return hasFlag("yes") || hasFlag("y")
2726+
? Promise.resolve(true)
2727+
: new Promise<boolean | symbol>((response, reject) => {
2728+
const prompt = new ConfirmPrompt(config);
27272729
27282730
prompt.on("state", state => config.onState?.(state));
27292731
prompt.on("submit", value => response(value));

packages/preset-cli/src/helpers/get-global-options.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ export function getGlobalOptions(
5555
required: false,
5656
default: false,
5757
isNegativeOf: "interactive"
58+
},
59+
context.config.interactive !== "never" &&
60+
context.config.interactive !== false && {
61+
name: "yes",
62+
title: "Yes",
63+
description:
64+
"Skip all prompts by answering yes to all of them - will be set to true if running in a CI pipeline.",
65+
alias: ["y"],
66+
type: "boolean",
67+
required: false,
68+
default: false
5869
}
5970
].filter(Boolean) as CommandOption[];
6071
}

0 commit comments

Comments
 (0)