diff --git a/deployment.coffee b/deployment.coffee index f3a2321..41cae5c 100644 --- a/deployment.coffee +++ b/deployment.coffee @@ -10,15 +10,33 @@ # fs = require 'fs' +deploymentDirectory = null + module.exports = (robot) -> + robot.hear /deploy set ([^\s]+) +(.+)$/i, (res) -> + if res.match[1] == "directory" + deploymentDirectory = res.match[2] + robot.hear /deploy +([^\s]+)( +with +([^\s]+))?( +from +branch +([^\s]+))? +to +([^\s]+)( +after (.*))?$/i, (res) -> + + if ! process.env.hasOwnProperty('HUBO_DEPLOYMENT_PROJECTS_DIRECTORY') + if deploymentDirectory == null + res.reply "You must set the env var HUBO_DEPLOYMENT_PROJECTS_DIRECTORY with the directory of the projects." + res.reply "Temporaly, you can use the command: deploy set directory " + return + project = res.match[1] target = res.match[6] program = if res.match[3] then res.match[3] else null branch = if res.match[5] then res.match[5] else null commands = if res.match[8] then cleanCommands res.match[8].split "," else [] - directory = "/home/simon/www/repo/" + project + if deploymentDirectory != null + directory = deploymentDirectory + else + directory = process.env.HUBO_DEPLOYMENT_PROJECTS_DIRECTORY + + directory += "/" + project try fs.stat directory, (err, stats) -> @@ -103,7 +121,6 @@ buildDeployCommand = (directory, program, target) -> command = interpreter + ' project:deploy ' + target + ' --go' command - cleanCommands = (commands) -> results = []