From 9fb05bea2b1e9403c55f1bf48af9365f8d0afd2f Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 29 Mar 2016 04:04:00 +0200 Subject: [PATCH] User `#` in environment variables as well --- scripts/shell.coffee | 8 ++++---- scripts/telegram.coffee | 2 +- test/autostart-test.coffee | 6 +++--- test/shell-test.coffee | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/shell.coffee b/scripts/shell.coffee index 8a2f585..de5e059 100644 --- a/scripts/shell.coffee +++ b/scripts/shell.coffee @@ -18,7 +18,7 @@ nope = ['BZBZ 400-BAD-REQUEST', 'BZBZ DOES-NOT-COMPUTE', isFromAdmin = (res) -> res.robot.adapterName is 'shell' or - res.message.user.room is process.env.ADMIN_ROOM?.replace(':','#') + res.message.room is process.env.ADMIN_ROOM runCmd = (cmd,res,cb) -> @@ -39,12 +39,12 @@ module.exports = (robot) -> # Lancia i test all'avvio if process.env.AUTO_RUN_TESTS and process.env.ADMIN_ROOM - dest = room: process.env.ADMIN_ROOM.replace(':','#') + dest = room: process.env.ADMIN_ROOM dest.send = (x) -> robot.send dest, x runCmd 'npm test', dest if process.env.AUTO_INFORM_ON_START - r = room: process.env.AUTO_INFORM_ON_START.replace(':','#') + r = room: process.env.AUTO_INFORM_ON_START robot.send r, 'asjon avviato e operativo!' robot.respond /aggiornati|scarica (?:gli )?aggiornamenti/i, (res) -> @@ -87,7 +87,7 @@ module.exports = (robot) -> robot.on 'githubhook', (data,params) -> if data.ref is 'refs/heads/master' and process.env.AUTO_KILL_ON_UPDATE - dest = name: params.name, room: params.room.replace(':','#') + dest = name: params.name, room: params.room res = send: (x) -> robot.send dest, x runCmd 'git pull && npm install', res, -> robot.send dest, 'riavvio in 5 SECONDI' diff --git a/scripts/telegram.coffee b/scripts/telegram.coffee index 7b187bc..7b8f9af 100644 --- a/scripts/telegram.coffee +++ b/scripts/telegram.coffee @@ -237,7 +237,7 @@ module.exports = (robot) -> 'invita anche me magari', 'che?'] user = res.message.user name = res.match[4] - admin_id = process.env['ADMIN_ROOM'].replace ':', '#' + admin_id = process.env['ADMIN_ROOM'] chat_list (list) -> if not (name in list) return res.send res.random failed diff --git a/test/autostart-test.coffee b/test/autostart-test.coffee index de77b21..eadcd6c 100644 --- a/test/autostart-test.coffee +++ b/test/autostart-test.coffee @@ -17,9 +17,9 @@ describe 'shell autostart', -> asjon.receive (e,l) -> l.join().should.equal 'asjon avviato e operativo!' done() - process.env.AUTO_INFORM_ON_START = ':mocha' + process.env.AUTO_INFORM_ON_START = '#mocha' process.env.AUTO_RUN_TESTS = '' - process.env.ADMIN_ROOM = ':mocha' + process.env.ADMIN_ROOM = '#mocha' require('../scripts/shell.coffee')(asjon.robot) it 'dovrebbe eseguire i test all\'avvio se richiesto', (done) -> @@ -32,5 +32,5 @@ describe 'shell autostart', -> acc++ if acc is 2 then done() process.env.AUTO_RUN_TESTS = 'true' - process.env.ADMIN_ROOM = ':mocha' + process.env.ADMIN_ROOM = '#mocha' require('../scripts/shell.coffee')(asjon.robot) diff --git a/test/shell-test.coffee b/test/shell-test.coffee index 1b56c40..b4835ef 100644 --- a/test/shell-test.coffee +++ b/test/shell-test.coffee @@ -18,7 +18,7 @@ describe 'modulo shell', -> asjon.receive (e,l) -> l.join().should.match /BZBZ (.+)/i done() - process.env.ADMIN_ROOM = ':not-mocha' + process.env.ADMIN_ROOM = '#not-mocha' asjon.send 'asjon controlla gli aggiornamenti' ss = ['operazione in corso: ', 'operazione "completata": '] @@ -30,7 +30,7 @@ describe 'modulo shell', -> l.join().should.match regexes[acc] acc++ if acc is 2 then done() - process.env.ADMIN_ROOM = ':mocha' + process.env.ADMIN_ROOM = '#mocha' asjon.send 'asjon controlla gli aggiornamenti' it 'dovrebbe eseguire i comandi corretti per installare gli aggiornamenti', (done) -> @@ -40,7 +40,7 @@ describe 'modulo shell', -> l.join().should.equal ss[acc]+cmd acc++ if acc is 2 then done() - process.env.ADMIN_ROOM = ':mocha' + process.env.ADMIN_ROOM = '#mocha' asjon.send 'asjon aggiornati' it 'dovrebbe eseguire i comandi corretti per controllare gli aggiornamenti', (done) -> @@ -50,7 +50,7 @@ describe 'modulo shell', -> l.join().should.equal ss[acc]+cmd acc++ if acc is 2 then done() - process.env.ADMIN_ROOM = ':mocha' + process.env.ADMIN_ROOM = '#mocha' asjon.send 'asjon controlla gli aggiornamenti' it 'dovrebbe eseguire i comandi corretti per installare le dipendenze', (done) -> @@ -60,7 +60,7 @@ describe 'modulo shell', -> l.join().should.equal ss[acc]+cmd acc++ if acc is 2 then done() - process.env.ADMIN_ROOM = ':mocha' + process.env.ADMIN_ROOM = '#mocha' asjon.send 'asjon installa le dipendenze' it 'dovrebbe eseguire i comandi corretti per eseguire i test', (done) -> @@ -70,12 +70,12 @@ describe 'modulo shell', -> l.join().should.equal ss[acc]+cmd acc++ if acc is 2 then done() - process.env.ADMIN_ROOM = ':mocha' + process.env.ADMIN_ROOM = '#mocha' asjon.send 'asjon esegui i test' it 'dovrebbe autoriavviarsi in caso di update se richiesto', (done) -> data = ref: 'refs/heads/master' - params = room: ':mocha', user: ':mocha' + params = room: '#mocha', user: '#mocha' acc = 0 asjon.receive (e,l) -> if acc is 0