summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2020-01-22 18:16:07 +0800
committerOpportunityLiu <[email protected]>2020-01-22 18:16:07 +0800
commit18aa8366b6c0f17f001dffe5dbcc494b0cc8e7dc (patch)
tree274c8f64ab6b3712aec8098926211303b328d0c8
parent17d5e2d5fd3f1d10c0598068cfd58412f848243e (diff)
raise when create in a no empty dir
-rw-r--r--xmake/actions/create/main.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/xmake/actions/create/main.lua b/xmake/actions/create/main.lua
index 55eca425f..2eee8bbdf 100644
--- a/xmake/actions/create/main.lua
+++ b/xmake/actions/create/main.lua
@@ -71,14 +71,19 @@ function _create_project(language, templateid, targetname)
-- get project directory
local projectdir = path.absolute(option.get("project") or path.join(os.curdir(), targetname))
- -- ensure the project directory
- if not os.isdir(projectdir) then
+ -- ensure the project directory
+ if not os.isdir(projectdir) then
os.mkdir(projectdir)
end
-- enter the project directory
os.cd(projectdir)
+ -- ensure the project directory is empty
+ if #os.filedirs('./*') ~= 0 then
+ raise("project directory (${underline}%s${reset}) is not empty!", path.relative(projectdir, os.workingdir()))
+ end
+
-- create project
local filedirs = {}
local sourcedir = path.join(tempinst:scriptdir(), "project")