UNPKG

detect-environment

Version:

Detect environments in JavaScript similar to the way Laravel does

53 lines (41 loc) 938 B
'use strict'; var // tmpl = require('lodash').template, yaml = require('js-yaml'), /** * */ parseEnvFile = function parseEnvFile (file, stamp) { // if (file === '') { return {}; } // if (stamp !== null && stamp !== undefined) { // if (Object.prototype.toString.call(stamp) !== '[object Object]') { throw new TypeError('parseEnvFile:'); } // try { file = tmpl(file, stamp); } catch (err) { throw err; } } // try { file = yaml.safeLoad(file); } catch (err) { throw new Error('parseEnvFile:'); } // if (!file) { file = {}; } // return file; }; // Expose to node.js module.exports = parseEnvFile;