diff --git a/scripts/github.coffee b/scripts/github.coffee index 0e1207f..73c1b06 100644 --- a/scripts/github.coffee +++ b/scripts/github.coffee @@ -14,10 +14,6 @@ GitHubAPI = require 'github' github = new GitHubAPI version: '3.0.0' module.exports = (robot) -> - if process.env.AUTO_INFORM_ON_START - r = room: process.env.AUTO_INFORM_ON_START.replace(':','#') - robot.send r, 'asjon avviato e operativo!' - githubhook = (req, res) -> res.send 200 dest = name: req.params.name, room: req.params.room.replace(':','#') diff --git a/scripts/shell.coffee b/scripts/shell.coffee index 7013eca..e39ace5 100644 --- a/scripts/shell.coffee +++ b/scripts/shell.coffee @@ -32,6 +32,10 @@ runCmd = (cmd,res,cb) -> if cb? then cb err,stdout,stderr module.exports = (robot) -> + if process.env.AUTO_INFORM_ON_START + r = room: process.env.AUTO_INFORM_ON_START.replace(':','#') + robot.send r, 'asjon avviato e operativo!' + robot.respond /aggiornati|scarica (?:gli )?aggiornamenti/i, (res) -> if !isFromAdmin(res) then return res.send res.random nope runCmd 'git pull && npm install', res @@ -51,12 +55,8 @@ module.exports = (robot) -> # Run tests on boot and report to ADMIN if process.env.AUTO_RUN_TESTS and process.env.ADMIN_ROOM dest = room: process.env.ADMIN_ROOM.replace(':','#') - robot.send dest, 'Operazione in corso: npm test' - runCmd 'npm test', dest, (err,stdout,stderr) -> - if err - robot.send dest, 'ATTENZIONE: TEST FAILURE\n'+stdout+stderr - else - robot.send dest, 'Test superati con successo:\n'+stdout + dest.send = (x) -> robot.send dest, x + runCmd 'npm test', dest robot.on 'githubhook', (data,params) -> if data.ref is 'refs/heads/master' and process.env.AUTO_KILL_ON_UPDATE