I wrote this beauty a while back to run on a server and convert environment variables from JSON
to a bash .env
format.
#!/usr/bin/env node
var strings = []
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(data) {
var json = JSON.parse(data)
for (var key in json) {
var val = json[key]
strings.push(key + '="' + val + '"')
}
})
process.stdin.on('end', function() {
var output = strings.join('\n')
process.stdout.write(output)
})
Can this be done without node, just bash? I'm having trouble getting this working on a server without node installed or without the correct path specified.