+2
-3
| { | ||
| "name": "parfait", | ||
| "version": "0.5.0", | ||
| "version": "0.7.0", | ||
| "author": "David M. Lee, II <leedm777@yahoo.com>", | ||
@@ -35,4 +35,3 @@ "description": "A sweet multi-layered configuration framework", | ||
| "coffeelint": "^1.2.0", | ||
| "mocha": "^1.18.2", | ||
| "sinon": "^1.9.1" | ||
| "mocha": "^1.18.2" | ||
| }, | ||
@@ -39,0 +38,0 @@ "license": "MIT", |
+16
-14
@@ -5,3 +5,3 @@ # Copyright (c) 2014. David M. Lee, II <leedm777@yahoo.com> | ||
| Promise = (require 'es6-promise').Promise | ||
| appdirsDefault = require 'appdirs' | ||
| appdirs = require 'appdirs' | ||
| confmerge = require './confmerge' | ||
@@ -20,7 +20,5 @@ jsyaml = require 'js-yaml' | ||
| @param {*} postConfig Config to merge on top of final result. | ||
| @param {appdirs} appdirs Methods `siteDataDir` and `userDataDir` for locating | ||
| site and user data directories, respectively. | ||
| @return {Promise<Object>} Consolidated configuration object. | ||
| ### | ||
| configure = ({environment, directory, preConfig, postConfig, appdirs}) -> | ||
| configure = ({environment, directory, preConfig, postConfig}) -> | ||
| environment ?= (process.env && process.env.NODE_ENV) || 'development' | ||
@@ -30,3 +28,2 @@ directory ?= 'config' | ||
| postConfig ?= {} | ||
| appdirs ?= appdirsDefault | ||
@@ -43,21 +40,26 @@ envDirectory = (dir) -> | ||
| .then (baseEnvConfig) -> | ||
| appdirsConfig = baseEnvConfig.appdirs || {} | ||
| appName = appdirsConfig.appName | ||
| appAuthor = appdirsConfig.appAuthor | ||
| app = baseEnvConfig.appdirs || {} | ||
| appName = app.appName | ||
| appAuthor = app.appAuthor | ||
| if appName | ||
| siteDir = appdirs.siteDataDir(appName, appAuthor) | ||
| userDir = appdirs.userDataDir(appName, appAuthor) | ||
| a = new appdirs.AppDirs(appName, appAuthor) | ||
| app.siteConfigDir ?= a.siteConfigDir() | ||
| app.siteDataDir ?= a.siteDataDir() | ||
| app.userCacheDir ?= a.userCacheDir() | ||
| app.userConfigDir ?= a.userConfigDir() | ||
| app.userDataDir ?= a.userDataDir() | ||
| app.userLogDir ?= a.userLogDir() | ||
| # Now the site config | ||
| processDirectory siteDir, baseEnvConfig | ||
| processDirectory app.siteConfigDir, baseEnvConfig | ||
| .then (siteConfig) -> | ||
| # Now the environment specific site config | ||
| processDirectory envDirectory(siteDir), siteConfig | ||
| processDirectory envDirectory(app.siteConfigDir), siteConfig | ||
| .then (siteEnvConfig) -> | ||
| # Now the user config | ||
| processDirectory userDir, siteEnvConfig | ||
| processDirectory app.userConfigDir, siteEnvConfig | ||
| .then (userConfig) -> | ||
| # Now the environment specific user config | ||
| processDirectory envDirectory(userDir), userConfig | ||
| processDirectory envDirectory(app.userConfigDir), userConfig | ||
| .then (userEnvConfig) -> | ||
@@ -64,0 +66,0 @@ confmerge userEnvConfig, postConfig |
6
-14.29%14264
-0.06%