Skip to content

Commit dbcdfcf

Browse files
committed
Add environment variables to output of 'dump'
1 parent 30af1b3 commit dbcdfcf

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/conf.coffee

+17-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ module.exports = (robot) ->
2626
unspaced = (spaced) ->
2727
spaced.replace /\s+/g, "."
2828

29+
unique = (arr) ->
30+
output = {}
31+
output[arr[key]] = arr[key] for key in [0...arr.length]
32+
value for key, value of output
33+
2934
robot.respond ///conf\s+get\s+"(#{SPACED_IDENTIFIER})"///, (res) ->
3035
respondGet res, unspaced(res.match[1])
3136

@@ -84,7 +89,17 @@ module.exports = (robot) ->
8489

8590
respondDump = (res, prefix) ->
8691
response = []
87-
for key in conf.keys()
92+
keys = conf.keys()
93+
fixCase = (key) ->
94+
key.toLowerCase().replace(/_/g, '.').substring('HUBOT_'.length)
95+
envs = (fixCase(key) for own key, val of process.env when key.indexOf('HUBOT_') is 0)
96+
keys = unique(keys.concat(envs))
97+
keys.sort()
98+
for key in keys
8899
if (not prefix?) or key.indexOf(prefix) is 0
89-
response.push "#{key} = `#{JSON.stringify conf.get key}`"
100+
[value, set] = common.resolveStat conf, key
101+
if set
102+
response.push "#{key} = `#{JSON.stringify value}`"
103+
else
104+
response.push "#{key} = `#{JSON.stringify value}` (environment variable)"
90105
res.send response.join "\n"

0 commit comments

Comments
 (0)