Skip to content

Instantly share code, notes, and snippets.

Last active Oct 10, 2015
What would you like to do?
New line parse in environment variables
// set the TEST environment variable with TEST=first line\\n\\nsecond line\\n
// you need to duplicate the \ to scape it
function parseEnvVarible(envVar){
return new Buffer(envVar.split('\\n').join(require('os').EOL), 'UTF-8').toString('UTF-8');
console.log('Wrong: ' + process.env.TEST);
console.log('Right: ' + parseEnvVarible(process.env.TEST));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment