]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
feat: add force overwrite option
authorHaoqun Jiang <haoqunjiang@gmail.com>
Wed, 11 Aug 2021 07:53:22 +0000 (15:53 +0800)
committerHaoqun Jiang <haoqunjiang@gmail.com>
Wed, 11 Aug 2021 07:54:14 +0000 (15:54 +0800)
index.js
snapshot.js

index 8911d90fd885f51a41296fc390e1b0853906c0f5..a5ea16fb7310b75fc9d03ff013a437937c1323f2 100755 (executable)
--- 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 === '.'
index a42018f14a83422fd7a143c1307ea33dd5f28ba3..f80cff6dff0a37a97ae9a9401a8b14f8503fc2c4 100644 (file)
@@ -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']