From e9473ef22e0ba3e20722b71f21d2231ccdc1d28e Mon Sep 17 00:00:00 2001 From: Blake Friedman Date: Thu, 20 Jun 2024 14:06:53 +0100 Subject: [PATCH] fix: only show warning about --template & --version when necessary This is showing at all times, instead of when it's needed. --- packages/cli/src/commands/init/init.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/commands/init/init.ts b/packages/cli/src/commands/init/init.ts index 23a747db0..0e17c8249 100644 --- a/packages/cli/src/commands/init/init.ts +++ b/packages/cli/src/commands/init/init.ts @@ -570,14 +570,16 @@ export default (async function initialize( // From 0.75 it actually is useful to be able to specify both the template and react-native version. // This should only be used by people who know what they're doing. - if (semver.gte(version, TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION)) { - logger.warn( - `Use ${chalk.bold('--template')} and ${chalk.bold( - '--version', - )} only if you know what you're doing. Here be dragons 🐉.`, - ); - } else if (!!options.template && !!options.version) { - throw new TemplateAndVersionError(options.template); + if (!!options.template && !!options.version) { + if (semver.gte(version, TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION)) { + logger.warn( + `Use ${chalk.bold('--template')} and ${chalk.bold( + '--version', + )} only if you know what you're doing. Here be dragons 🐉.`, + ); + } else { + throw new TemplateAndVersionError(options.template); + } } const root = process.cwd();