Skip to content

Commit adec95d

Browse files
committed
feat: add force overwrite option
1 parent ea858fa commit adec95d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ async function init() {
5050
// --router / --vue-router
5151
// --vuex
5252
// --with-tests / --tests / --cypress
53+
// --force (for force overwriting)
5354
const argv = minimist(process.argv.slice(2), {
5455
alias: {
5556
typescript: ['ts'],
@@ -75,6 +76,8 @@ async function init() {
7576
let targetDir = argv._[0]
7677
const defaultProjectName = !targetDir ? 'vue-project' : targetDir
7778

79+
const forceOverwrite = argv.force
80+
7881
let result = {}
7982

8083
try {
@@ -99,7 +102,8 @@ async function init() {
99102
},
100103
{
101104
name: 'shouldOverwrite',
102-
type: () => (canSafelyOverwrite(targetDir) ? null : 'confirm'),
105+
type: () =>
106+
canSafelyOverwrite(targetDir) || forceOverwrite ? null : 'confirm',
103107
message: () => {
104108
const dirForPrompt =
105109
targetDir === '.'

snapshot.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ const playgroundDir = new URL('./playground/', import.meta.url).pathname
66
function createProjectWithFeatureFlags(flags) {
77
const projectName = flags.join('-')
88
console.log(`Creating project ${projectName}`)
9-
spawnSync('node', [bin, projectName, ...flags.map((flag) => `--${flag}`)], {
10-
cwd: playgroundDir
11-
})
9+
spawnSync(
10+
'node',
11+
[bin, projectName, ...flags.map((flag) => `--${flag}`), '--force'],
12+
{
13+
cwd: playgroundDir
14+
}
15+
)
1216
}
1317

1418
const featureFlags = ['typescript', 'jsx', 'router', 'vuex', 'with-tests']

0 commit comments

Comments
 (0)