Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cli
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lhfe
cli
Commits
2804ec08
Commit
2804ec08
authored
Apr 01, 2021
by
lipengcheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fse
parent
4d245098
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
create.js
lib/create.js
+5
-5
No files found.
lib/create.js
View file @
2804ec08
const
path
=
require
(
'path'
)
const
path
=
require
(
'path'
)
const
fs
=
require
(
'fs-extra'
);
const
fs
e
=
require
(
'fs-extra'
);
const
inquirer
=
require
(
'inquirer'
);
const
inquirer
=
require
(
'inquirer'
);
const
prompts
=
require
(
'./prompts'
)
const
prompts
=
require
(
'./prompts'
)
const
Creator
=
require
(
'./Creator'
)
const
Creator
=
require
(
'./Creator'
)
...
@@ -27,13 +27,13 @@ module.exports = async function(projectname, options){
...
@@ -27,13 +27,13 @@ module.exports = async function(projectname, options){
validatePkgName
(
pkgName
)
validatePkgName
(
pkgName
)
// 已存在同名目录
// 已存在同名目录
if
(
!
inCurrent
&&
fs
.
existsSync
(
targetDir
)){
if
(
!
inCurrent
&&
fs
e
.
existsSync
(
targetDir
)){
// 有force参数,直接强制删除
// 有force参数,直接强制删除
// todo: 强制删除前,如果现有目录非空,可以给出提示
// todo: 强制删除前,如果现有目录非空,可以给出提示
// const files = fs
.existsSync(outDir) ? fs
.readdirSync(outDir) : []
// const files = fs
e.existsSync(outDir) ? fse
.readdirSync(outDir) : []
// files.length
// files.length
if
(
options
.
force
){
if
(
options
.
force
){
await
fs
.
remove
(
targetDir
)
await
fs
e
.
remove
(
targetDir
)
}
else
{
}
else
{
// 提示是否要覆盖
// 提示是否要覆盖
const
answers
=
await
inquirer
.
prompt
(
prompts
.
overwrite
)
const
answers
=
await
inquirer
.
prompt
(
prompts
.
overwrite
)
...
@@ -43,7 +43,7 @@ module.exports = async function(projectname, options){
...
@@ -43,7 +43,7 @@ module.exports = async function(projectname, options){
return
return
}
else
if
(
action
===
'overwrite'
)
{
}
else
if
(
action
===
'overwrite'
)
{
console
.
log
(
`\nRemoving
${
chalk
.
cyan
(
targetDir
)}
...`
)
console
.
log
(
`\nRemoving
${
chalk
.
cyan
(
targetDir
)}
...`
)
fs
.
remove
(
targetDir
)
fs
e
.
remove
(
targetDir
)
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment