configuring
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact" | ||
], | ||
} |
export interface ConfigManagerOptions<TConfig> { | ||
configurations: { | ||
default: Partial<TConfig>; | ||
default: TConfig; | ||
[env: string]: Partial<TConfig>; | ||
@@ -9,5 +9,5 @@ }; | ||
get: (key: string, env?: string) => any; | ||
getConfig: (env?: string) => Partial<TConfig> | undefined; | ||
getConfig: (env?: string) => TConfig; | ||
} | ||
export declare const createConfigManager: <TConfig>(options: ConfigManagerOptions<TConfig>) => ConfigurationManager<TConfig>; | ||
export default createConfigManager; |
@@ -51,9 +51,10 @@ 'use strict'; | ||
var config = configurationManager.getConfig(env); | ||
if (config === null) { | ||
throw new Error("No configuration for environment \"" + (env || 'default') + "\""); | ||
} | ||
return get(config, key); | ||
}, | ||
getConfig: function (env) { | ||
return getFitEnvironmentConfig(env); | ||
var config = getFitEnvironmentConfig(env); | ||
if (!config) { | ||
throw new Error("No configuration for environment \"" + (env || 'default') + "\""); | ||
} | ||
return config; | ||
}, | ||
@@ -60,0 +61,0 @@ }; |
@@ -45,9 +45,10 @@ import defaultsDeep from 'lodash/defaultsDeep'; | ||
var config = configurationManager.getConfig(env); | ||
if (config === null) { | ||
throw new Error("No configuration for environment \"" + (env || 'default') + "\""); | ||
} | ||
return get(config, key); | ||
}, | ||
getConfig: function (env) { | ||
return getFitEnvironmentConfig(env); | ||
var config = getFitEnvironmentConfig(env); | ||
if (!config) { | ||
throw new Error("No configuration for environment \"" + (env || 'default') + "\""); | ||
} | ||
return config; | ||
}, | ||
@@ -54,0 +55,0 @@ }; |
{ | ||
"name": "configuring", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A configuration system for typescript projects", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -7,3 +7,3 @@ import defaultsDeep from 'lodash/defaultsDeep'; | ||
configurations: { | ||
default: Partial<TConfig>; | ||
default: TConfig; | ||
[env: string]: Partial<TConfig>; | ||
@@ -15,3 +15,3 @@ }; | ||
get: (key: string, env?: string) => any; | ||
getConfig: (env?: string) => Partial<TConfig> | undefined; | ||
getConfig: (env?: string) => TConfig; | ||
} | ||
@@ -31,3 +31,3 @@ | ||
const { configurations } = options; | ||
const configSet = new Map<string, Partial<TConfig>>(); | ||
const configSet = new Map<string, TConfig>(); | ||
@@ -64,3 +64,8 @@ configSet.set('default', configurations.default); | ||
const config = configurationManager.getConfig(env); | ||
if (config === null) { | ||
return get(config, key); | ||
}, | ||
getConfig: (env) => { | ||
const config = getFitEnvironmentConfig(env); | ||
if (!config) { | ||
throw new Error( | ||
@@ -70,8 +75,4 @@ `No configuration for environment "${env || 'default'}"` | ||
} | ||
return get(config, key); | ||
return config; | ||
}, | ||
getConfig: (env) => { | ||
return getFitEnvironmentConfig(env); | ||
}, | ||
}; | ||
@@ -78,0 +79,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10883
304