Bug Fixes
This commit is contained in:
1 parent
82bc086e92
commit
b1af6e078c
131 files changed
+8597
-1930
No files matched your search
+3
-2
@@ -31,6 +31,7 @@ function log (message /*: string */) {
|
||||
const NEWLINE = '\n'
|
||||
const RE_INI_KEY_VAL = /^\s*([\w.-]+)\s*=\s*(.*)?\s*$/
|
||||
const RE_NEWLINES = /\\n/g
|
||||
const NEWLINES_MATCH = /\n|\r|\r\n/
|
||||
|
||||
// Parses src into an Object
|
||||
function parse (src /*: string | Buffer */, options /*: ?DotenvParseOptions */) /*: DotenvParseOutput */ {
|
||||
@@ -38,7 +39,7 @@ function parse (src /*: string | Buffer */, options /*: ?DotenvParseOptions */)
|
||||
const obj = {}
|
||||
|
||||
// convert Buffers before splitting into lines and processing
|
||||
src.toString().split(NEWLINE).forEach(function (line, idx) {
|
||||
src.toString().split(NEWLINES_MATCH).forEach(function (line, idx) {
|
||||
// matching "KEY' and 'VAL' in 'KEY=VAL'
|
||||
const keyValueArr = line.match(RE_INI_KEY_VAL)
|
||||
// matched?
|
||||
@@ -95,7 +96,7 @@ function config (options /*: ?DotenvConfigOptions */) /*: DotenvConfigOutput */
|
||||
const parsed = parse(fs.readFileSync(dotenvPath, { encoding }), { debug })
|
||||
|
||||
Object.keys(parsed).forEach(function (key) {
|
||||
if (!process.env.hasOwnProperty(key)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
|
||||
process.env[key] = parsed[key]
|
||||
} else if (debug) {
|
||||
log(`"${key}" is already defined in \`process.env\` and will not be overwritten`)
|
||||
|
||||
Reference in new issue
Block a user