From adec95debfe730576d5fc81b4b3b64a11630c7f8 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 11 Aug 2021 15:53:22 +0800 Subject: [PATCH] feat: add force overwrite option --- index.js | 6 +++++- snapshot.js | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 8911d90f..a5ea16fb 100755 --- a/index.js +++ b/index.js @@ -50,6 +50,7 @@ async function init() { // --router / --vue-router // --vuex // --with-tests / --tests / --cypress + // --force (for force overwriting) const argv = minimist(process.argv.slice(2), { alias: { typescript: ['ts'], @@ -75,6 +76,8 @@ async function init() { let targetDir = argv._[0] const defaultProjectName = !targetDir ? 'vue-project' : targetDir + const forceOverwrite = argv.force + let result = {} try { @@ -99,7 +102,8 @@ async function init() { }, { name: 'shouldOverwrite', - type: () => (canSafelyOverwrite(targetDir) ? null : 'confirm'), + type: () => + canSafelyOverwrite(targetDir) || forceOverwrite ? null : 'confirm', message: () => { const dirForPrompt = targetDir === '.' diff --git a/snapshot.js b/snapshot.js index a42018f1..f80cff6d 100644 --- a/snapshot.js +++ b/snapshot.js @@ -6,9 +6,13 @@ const playgroundDir = new URL('./playground/', import.meta.url).pathname function createProjectWithFeatureFlags(flags) { const projectName = flags.join('-') console.log(`Creating project ${projectName}`) - spawnSync('node', [bin, projectName, ...flags.map((flag) => `--${flag}`)], { - cwd: playgroundDir - }) + spawnSync( + 'node', + [bin, projectName, ...flags.map((flag) => `--${flag}`), '--force'], + { + cwd: playgroundDir + } + ) } const featureFlags = ['typescript', 'jsx', 'router', 'vuex', 'with-tests'] -- 2.39.5