This commit is contained in:
Simon Vieille 2016-01-23 11:24:19 +01:00
parent 4fb251d788
commit 350af4c943

View file

@ -54,7 +54,8 @@ module.exports = (robot) ->
catch e
if pv
deploy directory, pv, commands, target, program
d = deploy directory, pv, commands, target, program
res.reply d
else
res.reply "Not a SVN or GIT repository"
catch e
@ -88,18 +89,52 @@ class GitProjectVersionning extends ProjectVersionning
logExec = (command, options) ->
exec = require "sync-exec"
console.log command
exec command, options
deploy = (directory, projectVersionning, commands, target, program) ->
commands = projectVersionning.getUpdateCommands().concat(commands)
canDeploy = true
results = []
for command in commands
logExec command , {cwd: directory}
for command in commands
if !canDeploy
continue
logExec buildDeployCommand(directory, program, target), {cwd: directory}
stmt = logExec command , {cwd: directory}
results.push {
command: command,
status: stmt.status,
stdout: stmt.stdout,
stderr: stmt.stderr,
}
if stmt.status != 0
canDeploy = false
if canDeploy
command = buildDeployCommand(directory, program, target)
stmt = logExec command, {cwd: directory}
results.push {
command: command,
status: stmt.status,
stdout: stmt.stdout,
stderr: stmt.stderr,
}
output = ""
for stmt in results
status = if stmt.status == 0 then 'OK' else 'KO'
output += "`#{stmt.command}` is *#{status}*\n"
if stmt.status != 0
output += "\n```#{stmt.stdout} #{stmt.stderr}```"
output
buildDeployCommand = (directory, program, target) ->
if program == 'mage'