Skip to content

Commit

Permalink
feat: add install flag to bypass prompt (#625)
Browse files Browse the repository at this point in the history
* feat: add install flag to bypass prompt

* fix: change flag to --yes
  • Loading branch information
ezraripps authored Mar 17, 2023
1 parent ebb90af commit 415fb8e
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions packages/api/src/cli/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ cmd
'ts',
])
)
.action(async (uri: string, options: { lang: string }) => {
.addOption(new Option('-y, --yes', 'Automatically answer "yes" to any prompts printed'))
.action(async (uri: string, options: { lang: string; yes?: boolean }) => {
let language: SupportedLanguages;
if (options.lang) {
language = options.lang as SupportedLanguages;
Expand Down Expand Up @@ -155,18 +156,20 @@ cmd
logger(` ${figures.pointerSmall} ${pkg}: ${pkgInfo.reason} ${pkgInfo.url}`);
});

await promptTerminal({
type: 'confirm',
name: 'value',
message: 'OK to proceed with package installation?',
initial: true,
}).then(({ value }) => {
if (!value) {
// @todo cleanup installed files
logger('Installation cancelled.', true);
process.exit(1);
}
});
if (!options.yes) {
await promptTerminal({
type: 'confirm',
name: 'value',
message: 'OK to proceed with package installation?',
initial: true,
}).then(({ value }) => {
if (!value) {
// @todo cleanup installed files
logger('Installation cancelled.', true);
process.exit(1);
}
});
}

spinner = ora('Installing required packages').start();
try {
Expand Down

0 comments on commit 415fb8e

Please sign in to comment.