frack-settings
Advanced tools
Comparing version 0.0.9 to 0.0.10
{ | ||
"name": "frack-settings", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Settings defaults and runtime loader from rc file", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -0,1 +1,2 @@ | ||
// @flow | ||
import deepMerge from 'deepmerge' | ||
@@ -5,33 +6,38 @@ import defaultSettings from './defaultSettings' | ||
import has from 'lodash/fp/has' | ||
import { resolve } from 'path' | ||
import { join } from 'path' | ||
const frackRcPath = resolve(process.cwd(), '.frackrc.js') | ||
function getFrackRc () { | ||
const frackRcPath = join(process.cwd(), '.frackrc.js') | ||
let frackSettings = { | ||
common: defaultSettings, | ||
development: defaultSettings, | ||
production: defaultSettings, | ||
} | ||
let frackSettings = { | ||
common: defaultSettings, | ||
development: defaultSettings, | ||
production: defaultSettings, | ||
} | ||
if (existsSync(frackRcPath)) { | ||
const frackRc = require(frackRcPath) | ||
const hasCommon = has('common') | ||
const hasDevelopment = has('development') | ||
const hasProduction = has('production') | ||
if ( | ||
typeof frackRc === 'object' && | ||
hasCommon(frackRc) && | ||
hasDevelopment(frackRc) && | ||
hasProduction(frackRc) | ||
) { | ||
frackSettings = deepMerge(frackSettings, frackRc) | ||
if (existsSync(frackRcPath)) { | ||
const frackRc = require(frackRcPath) | ||
const hasCommon = has('common') | ||
const hasDevelopment = has('development') | ||
const hasProduction = has('production') | ||
if ( | ||
typeof frackRc === 'object' && | ||
hasCommon(frackRc) && | ||
hasDevelopment(frackRc) && | ||
hasProduction(frackRc) | ||
) { | ||
frackSettings = deepMerge(frackSettings, frackRc) | ||
} else { | ||
throw new Error('File .frackrc.js containing application settings was not found.') | ||
} | ||
} else { | ||
throw new Error('File .frackrc.js containing application settings was not found.') | ||
throw new Error('File .frackrc.js not found on path ' + frackRcPath) | ||
} | ||
} else { | ||
throw new Error('File .frackrc.js not found on path ' + frackRcPath) | ||
return frackSettings | ||
} | ||
let frackSettings = getFrackRc() | ||
const currentEnv = process.env.NODE_ENV || 'development' | ||
export default deepMerge(frackSettings[currentEnv], frackSettings['common']) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
210600
6161