User # in environment variables as well

This commit is contained in:
rnhmjoj 2016-03-29 04:04:00 +02:00
parent 22dfe75947
commit d3319c0bd0
4 changed files with 15 additions and 15 deletions

View File

@ -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'

View File

@ -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

View File

@ -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)

View File

@ -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