Skip to content

Instantly share code, notes, and snippets.

@manrueda manrueda/example.js
Last active Oct 10, 2015

Embed
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
You can’t perform that action at this time.