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 = []