Skip to content

Commit 415fb8e

Browse files
authored
feat: add install flag to bypass prompt (#625)
* feat: add install flag to bypass prompt * fix: change flag to --yes
1 parent ebb90af commit 415fb8e

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

packages/api/src/cli/commands/install.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ cmd
2626
'ts',
2727
])
2828
)
29-
.action(async (uri: string, options: { lang: string }) => {
29+
.addOption(new Option('-y, --yes', 'Automatically answer "yes" to any prompts printed'))
30+
.action(async (uri: string, options: { lang: string; yes?: boolean }) => {
3031
let language: SupportedLanguages;
3132
if (options.lang) {
3233
language = options.lang as SupportedLanguages;
@@ -155,18 +156,20 @@ cmd
155156
logger(` ${figures.pointerSmall} ${pkg}: ${pkgInfo.reason} ${pkgInfo.url}`);
156157
});
157158

158-
await promptTerminal({
159-
type: 'confirm',
160-
name: 'value',
161-
message: 'OK to proceed with package installation?',
162-
initial: true,
163-
}).then(({ value }) => {
164-
if (!value) {
165-
// @todo cleanup installed files
166-
logger('Installation cancelled.', true);
167-
process.exit(1);
168-
}
169-
});
159+
if (!options.yes) {
160+
await promptTerminal({
161+
type: 'confirm',
162+
name: 'value',
163+
message: 'OK to proceed with package installation?',
164+
initial: true,
165+
}).then(({ value }) => {
166+
if (!value) {
167+
// @todo cleanup installed files
168+
logger('Installation cancelled.', true);
169+
process.exit(1);
170+
}
171+
});
172+
}
170173

171174
spinner = ora('Installing required packages').start();
172175
try {

0 commit comments

Comments
 (0)