From bd26e8cbfe8cf005bc2c0d66752482c4072e86d1 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 21 Jan 2016 16:38:31 +0100 Subject: [PATCH] Deployment commands --- deployment.coffee | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/deployment.coffee b/deployment.coffee index 6f99b8f..21f3509 100644 --- a/deployment.coffee +++ b/deployment.coffee @@ -26,16 +26,20 @@ module.exports = (robot) -> if err != null or !stats.isDirectory return res.reply "Project not found [" + directory + "]" - process.chdir(directory) - - fs.stat '.svn', (err, stats) -> - if err == null - deploy new SvnProjectVersionning(branch), commands + try + fs.statSync directory + '/.svn' + pv = new SvnProjectVersionning branch + catch e - fs.stat '.git', (err, stats) -> - if err == null - deploy new GitProjectVersionning(branch), commands + try + fs.statSync directory + '/.git' + pv = new GitProjectVersionning branch + catch e + if pv + deploy directory, pv, commands + else + res.reply "Not a SVN or GIT repository" catch e res.reply "Exception: " + e @@ -65,8 +69,12 @@ class GitProjectVersionning extends ProjectVersionning commands -deploy = (projectVersionning, commands) -> - console.log projectVersionning.getUpdateCommands() +deploy = (directory, projectVersionning, commands) -> + exec = require('sync-exec'); + commands = projectVersionning.getUpdateCommands().concat(commands) + + for command in commands + exec command, {cwd: directory} cleanCommands = (commands) -> results = []