summaryrefslogtreecommitdiff
path: root/xmake/scripts/action/_create.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-20 19:53:54 +0800
committerruki <[email protected]>2015-06-20 19:53:54 +0800
commitcd3922c36588023c8e0ffaeccb2fc2c95b05dd20 (patch)
treea4597c30d982140a85d14c9cc4359f5555780834 /xmake/scripts/action/_create.lua
parent12e518a819bb848c67452655abdfcce5c0d90bd2 (diff)
move some template implementation
Diffstat (limited to 'xmake/scripts/action/_create.lua')
-rw-r--r--xmake/scripts/action/_create.lua27
1 files changed, 23 insertions, 4 deletions
diff --git a/xmake/scripts/action/_create.lua b/xmake/scripts/action/_create.lua
index 47d0d2761..a49dd4915 100644
--- a/xmake/scripts/action/_create.lua
+++ b/xmake/scripts/action/_create.lua
@@ -45,7 +45,7 @@ function _create.done()
local targetname = options.target or path.basename(xmake._PROJECT_DIR) or "demo"
-- trace
- utils.printf("create project %s ...", targetname)
+ utils.printf("create %s ...", targetname)
-- the language
local language = options.language
@@ -79,14 +79,33 @@ function _create.done()
return false
end
- -- done the template and create this project
+ -- check the template project
+ if not os.isdir("project") then
+ -- errors
+ utils.error("the template project not exists!")
+ return false
+ end
+
+ -- ensure the project directory
+ if not os.isdir(xmake._PROJECT_DIR) then
+ os.mkdir(xmake._PROJECT_DIR)
+ end
+
+ -- copy the project files
+ if not os.cp("project/*", xmake._PROJECT_DIR) then
+ -- errors
+ utils.error("copy files failed!")
+ return false
+ end
+
+ -- done the template files
if not module.done(targetname, xmake._PROJECT_DIR) then
- utils.error("create project %s failed!", targetname)
+ utils.error("update the template failed!")
return false
end
-- trace
- utils.printf("create project %s ok!", targetname)
+ utils.printf("create %s ok!", targetname)
-- ok
return true