@spinajs/configuration
Advanced tools
Comparing version 2.0.238 to 2.0.240
@@ -15,2 +15,3 @@ import { Configuration, ConfigurationSource, IConfigLike } from '@spinajs/configuration-common'; | ||
protected load(extension: string, callback: (file: string) => Promise<unknown>): Promise<{}>; | ||
protected getEnvironment(config: Configuration): string; | ||
} | ||
@@ -17,0 +18,0 @@ export declare class JsFileSource extends BaseFileSource { |
@@ -113,2 +113,15 @@ "use strict"; | ||
} | ||
getEnvironment(config) { | ||
const env = config.get('process.env.APP_ENV', 'production'); | ||
switch (env) { | ||
case 'dev': | ||
case 'development': | ||
return 'dev'; | ||
case 'prod': | ||
case 'production': | ||
return 'prod'; | ||
default: | ||
return env; | ||
} | ||
} | ||
} | ||
@@ -118,5 +131,5 @@ exports.BaseFileSource = BaseFileSource; | ||
async Load(config) { | ||
const common = await this.load('!(*.dev|*.prod).{cjs,js}', _load); | ||
const env = config.get('process.env.APP_ENV', 'production'); | ||
const fExt = env === 'development' ? '*.dev.{cjs,js}' : '*.prod.{cjs,js}'; | ||
const env = this.getEnvironment(config); | ||
const common = await this.load(`!(*.dev|*.prod|*.${env}).{cjs,js}`, _load); | ||
const fExt = `*.${env}.{cjs,js}`; | ||
const cfg = await this.load(fExt, _load); | ||
@@ -142,5 +155,5 @@ return lodash_1.default.mergeWith(common, cfg, util_js_1.mergeArrays); | ||
async Load(config) { | ||
const common = await this.load('!(*.dev|*.prod).json', _load); | ||
const env = config.get('process.env.APP_ENV', 'production'); | ||
const fExt = env === 'development' ? '*.dev.json' : '*.prod.json'; | ||
const env = this.getEnvironment(config); | ||
const common = await this.load(`!(*.dev|*.prod|*.${env}).json`, _load); | ||
const fExt = `*.${env}.json`; | ||
const cfg = await this.load(fExt, _load); | ||
@@ -147,0 +160,0 @@ return lodash_1.default.mergeWith(common, cfg, util_js_1.mergeArrays); |
@@ -15,2 +15,3 @@ import { Configuration, ConfigurationSource, IConfigLike } from '@spinajs/configuration-common'; | ||
protected load(extension: string, callback: (file: string) => Promise<unknown>): Promise<{}>; | ||
protected getEnvironment(config: Configuration): string; | ||
} | ||
@@ -17,0 +18,0 @@ export declare class JsFileSource extends BaseFileSource { |
@@ -84,8 +84,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
} | ||
getEnvironment(config) { | ||
const env = config.get('process.env.APP_ENV', 'production'); | ||
switch (env) { | ||
case 'dev': | ||
case 'development': | ||
return 'dev'; | ||
case 'prod': | ||
case 'production': | ||
return 'prod'; | ||
default: | ||
return env; | ||
} | ||
} | ||
} | ||
let JsFileSource = class JsFileSource extends BaseFileSource { | ||
async Load(config) { | ||
const common = await this.load('!(*.dev|*.prod).{cjs,js}', _load); | ||
const env = config.get('process.env.APP_ENV', 'production'); | ||
const fExt = env === 'development' ? '*.dev.{cjs,js}' : '*.prod.{cjs,js}'; | ||
const env = this.getEnvironment(config); | ||
const common = await this.load(`!(*.dev|*.prod|*.${env}).{cjs,js}`, _load); | ||
const fExt = `*.${env}.{cjs,js}`; | ||
const cfg = await this.load(fExt, _load); | ||
@@ -111,5 +124,5 @@ return _.mergeWith(common, cfg, mergeArrays); | ||
async Load(config) { | ||
const common = await this.load('!(*.dev|*.prod).json', _load); | ||
const env = config.get('process.env.APP_ENV', 'production'); | ||
const fExt = env === 'development' ? '*.dev.json' : '*.prod.json'; | ||
const env = this.getEnvironment(config); | ||
const common = await this.load(`!(*.dev|*.prod|*.${env}).json`, _load); | ||
const fExt = `*.${env}.json`; | ||
const cfg = await this.load(fExt, _load); | ||
@@ -116,0 +129,0 @@ return _.mergeWith(common, cfg, mergeArrays); |
{ | ||
"name": "@spinajs/configuration", | ||
"version": "2.0.238", | ||
"version": "2.0.240", | ||
"description": "framework configuration module", | ||
@@ -55,7 +55,7 @@ "main": "lib/cjs/index.js", | ||
"dependencies": { | ||
"@spinajs/configuration-common": "^2.0.238", | ||
"@spinajs/di": "^2.0.238", | ||
"@spinajs/exceptions": "^2.0.238", | ||
"@spinajs/internal-logger": "^2.0.238", | ||
"@spinajs/util": "2.0.238", | ||
"@spinajs/configuration-common": "^2.0.240", | ||
"@spinajs/di": "^2.0.240", | ||
"@spinajs/exceptions": "^2.0.240", | ||
"@spinajs/internal-logger": "^2.0.240", | ||
"@spinajs/util": "2.0.240", | ||
"ajv": "^8.12.0", | ||
@@ -62,0 +62,0 @@ "ajv-formats": "^2.1.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
255461
1636
+ Added@spinajs/util@2.0.240(transitive)
- Removed@spinajs/util@2.0.238(transitive)
Updated@spinajs/di@^2.0.240
Updated@spinajs/exceptions@^2.0.240
Updated@spinajs/util@2.0.240