Last active
October 10, 2015 20:58
-
-
Save manrueda/5dc1570f128a557ac345 to your computer and use it in GitHub Desktop.
New line parse in environment variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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