Skip to content

Instantly share code, notes, and snippets.

@thanpolas
Created March 6, 2014 22:43
Show Gist options
  • Save thanpolas/9401398 to your computer and use it in GitHub Desktop.
Save thanpolas/9401398 to your computer and use it in GitHub Desktop.
Setup Heroku sensitive configs
/**
* @fileOverview Passwords and sensitive shit.
*/
var exec = require('child_process').exec;
var local = false;
var herokuOverride = {
cookies: {
session: {
secret: 'xxx',
},
},
crypto: {
salt: 'xxx',
},
mongo: {
user: 'xx',
pass: 'xx',
hostname: 'xx',
},
redis: {
main: {
host: 'xx',
port: 'xxxx',
user: 'xx',
pass: 'xxx'
},
},
mandrill: {
apiKey: 'xxx',
}
};
var jsoned = JSON.stringify(herokuOverride);
var re = new RegExp('"', 'g');
var cmd;
if (local) {
cmd = 'export NODE_CONFIG="';
cmd += jsoned.replace(re, '\\"');
cmd += '"';
} else {
cmd = 'heroku config:set NODE_CONFIG="';
cmd += jsoned.replace(re, '\\"');
cmd += '" --app heroku-app';
}
console.log('Executing:\n', cmd);
exec(cmd, null, function (err, stdout, stderr) {
console.log('Finished executing:', err, stdout, stderr);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment