From 416f4e86e390318dbb0bdb262139ca4ec72ce5fe Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Tue, 13 Sep 2022 18:52:46 +0800 Subject: [PATCH] fix: support capital letter "Y" in command line prompt --- install.js | 2 +- packages/core/src/env-set/parameters.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/install.js b/install.js index 09619de88..b0c2dc6ff 100755 --- a/install.js +++ b/install.js @@ -19,7 +19,7 @@ const question = async (query) => new Promise((resolve) => { const confirm = async (query) => { const answer = await question(`${query} (Y/n) `); - return answer === '' || ['y', 'yes', 'yep', 'yeah'].includes(answer); + return answer === '' || ['y', 'yes', 'yep', 'yeah'].includes(answer.toLowerCase()); }; const safeExecSync = (command) => { diff --git a/packages/core/src/env-set/parameters.ts b/packages/core/src/env-set/parameters.ts index 6b4d8af8a..ba8c2fa99 100644 --- a/packages/core/src/env-set/parameters.ts +++ b/packages/core/src/env-set/parameters.ts @@ -1,6 +1,7 @@ import { getEnv } from '@silverhand/essentials'; -export const isTrue = (value: string) => ['1', 'true', 'y', 'yes', 'yep', 'yeah'].includes(value); +export const isTrue = (value: string) => + ['1', 'true', 'y', 'yes', 'yep', 'yeah'].includes(value.toLowerCase()); const parameters = new Set(process.argv.slice(2)); export const noInquiry = parameters.has('--no-inquiry') || isTrue(getEnv('NO_INQUIRY'));