Skip to content

Instantly share code, notes, and snippets.

@manrueda
Last active October 10, 2015 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manrueda/5dc1570f128a557ac345 to your computer and use it in GitHub Desktop.
Save manrueda/5dc1570f128a557ac345 to your computer and use it in GitHub Desktop.
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