From cd3922c36588023c8e0ffaeccb2fc2c95b05dd20 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 20 Jun 2015 19:53:54 +0800 Subject: move some template implementation --- xmake/scripts/action/_create.lua | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'xmake/scripts/action/_create.lua') 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 -- cgit v1.3.1