Commit 2804ec08 authored by lipengcheng 's avatar lipengcheng

fse

parent 4d245098
const path = require('path')
const fs = require('fs-extra');
const fse = require('fs-extra');
const inquirer = require('inquirer');
const prompts = require('./prompts')
const Creator = require('./Creator')
......@@ -27,13 +27,13 @@ module.exports = async function(projectname, options){
validatePkgName(pkgName)
// 已存在同名目录
if (!inCurrent && fs.existsSync(targetDir)){
if (!inCurrent && fse.existsSync(targetDir)){
// 有force参数,直接强制删除
// todo: 强制删除前,如果现有目录非空,可以给出提示
// const files = fs.existsSync(outDir) ? fs.readdirSync(outDir) : []
// const files = fse.existsSync(outDir) ? fse.readdirSync(outDir) : []
// files.length
if(options.force){
await fs.remove(targetDir)
await fse.remove(targetDir)
} else {
// 提示是否要覆盖
const answers = await inquirer.prompt(prompts.overwrite)
......@@ -43,7 +43,7 @@ module.exports = async function(projectname, options){
return
} else if (action === 'overwrite') {
console.log(`\nRemoving ${chalk.cyan(targetDir)}...`)
fs.remove(targetDir)
fse.remove(targetDir)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment