From 9b2b1e4322e03f7e22312e361c6afb1fc402e742 Mon Sep 17 00:00:00 2001 From: zhhbstudio Date: Fri, 11 Mar 2022 16:02:20 +0800 Subject: [PATCH] feat: use `??` instead of `||` (#78) Co-authored-by: zhaohebin --- index.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index a06e9a16..55eb4638 100755 --- a/index.js +++ b/index.js @@ -71,17 +71,16 @@ async function init() { }) // if any of the feature flags is set, we would skip the feature prompts - // use `??` instead of `||` once we drop Node.js 12 support const isFeatureFlagsUsed = typeof ( - argv.default || - argv.ts || - argv.jsx || - argv.router || - argv.pinia || - argv.tests || - argv.vitest || - argv.cypress || + argv.default ?? + argv.ts ?? + argv.jsx ?? + argv.router ?? + argv.pinia ?? + argv.tests ?? + argv.vitest ?? + argv.cypress ?? argv.eslint ) === 'boolean' @@ -227,7 +226,7 @@ async function init() { // so we still have to assign the default values here const { projectName, - packageName = projectName || defaultProjectName, + packageName = projectName ?? defaultProjectName, shouldOverwrite = argv.force, needsJsx = argv.jsx, needsTypeScript = argv.typescript, @@ -380,7 +379,7 @@ async function init() { fs.writeFileSync( path.resolve(root, 'README.md'), generateReadme({ - projectName: result.projectName || defaultProjectName, + projectName: result.projectName ?? defaultProjectName, packageManager, needsTypeScript, needsVitest, -- 2.39.5