@incanta/config
Advanced tools
Comparing version 0.1.18 to 0.1.19
@@ -19,2 +19,15 @@ "use strict"; | ||
this.customValues = {}; | ||
let defaultConfigDir = "config"; | ||
let defaultConfigEnv = "default"; | ||
if (fs_1.default.existsSync(path_1.default.join(process.cwd(), "config-settings.json"))) { | ||
const configSettings = JSON.parse(fs_1.default.readFileSync(path_1.default.join(process.cwd(), "config-settings.json"), "utf-8")); | ||
if (configSettings.defaults) { | ||
if (configSettings.defaults.dir) { | ||
defaultConfigDir = configSettings.defaults.configDir; | ||
} | ||
if (configSettings.defaults.env) { | ||
defaultConfigEnv = configSettings.defaults.env; | ||
} | ||
} | ||
} | ||
this.configDir = | ||
@@ -24,6 +37,6 @@ options?.configDir || | ||
path_1.default.relative(process.cwd(), process.env["NODE_CONFIG_DIR"])) || | ||
path_1.default.join(process.cwd(), "config"); | ||
path_1.default.join(process.cwd(), defaultConfigDir); | ||
const defaultValues = loader_1.Loader.load(path_1.default.join(this.configDir, "default")); | ||
let envValues = {}; | ||
const configEnvDir = options?.configEnv || process.env["NODE_CONFIG_ENV"]; | ||
const configEnvDir = options?.configEnv || process.env["NODE_CONFIG_ENV"] || defaultConfigEnv; | ||
if (configEnvDir) { | ||
@@ -30,0 +43,0 @@ if (fs_1.default.existsSync(path_1.default.join(this.configDir, configEnvDir))) { |
{ | ||
"name": "@incanta/config", | ||
"version": "0.1.18", | ||
"version": "0.1.19", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -23,2 +23,23 @@ import merge from "lodash.merge"; | ||
let defaultConfigDir = "config"; | ||
let defaultConfigEnv = "default"; | ||
if (fs.existsSync(path.join(process.cwd(), "config-settings.json"))) { | ||
const configSettings = JSON.parse( | ||
fs.readFileSync( | ||
path.join(process.cwd(), "config-settings.json"), | ||
"utf-8" | ||
) | ||
); | ||
if (configSettings.defaults) { | ||
if (configSettings.defaults.dir) { | ||
defaultConfigDir = configSettings.defaults.configDir; | ||
} | ||
if (configSettings.defaults.env) { | ||
defaultConfigEnv = configSettings.defaults.env; | ||
} | ||
} | ||
} | ||
this.configDir = | ||
@@ -28,3 +49,3 @@ options?.configDir || | ||
path.relative(process.cwd(), process.env["NODE_CONFIG_DIR"])) || | ||
path.join(process.cwd(), "config"); | ||
path.join(process.cwd(), defaultConfigDir); | ||
@@ -34,3 +55,4 @@ const defaultValues = Loader.load(path.join(this.configDir, "default")); | ||
let envValues: any = {}; | ||
const configEnvDir = options?.configEnv || process.env["NODE_CONFIG_ENV"]; | ||
const configEnvDir = | ||
options?.configEnv || process.env["NODE_CONFIG_ENV"] || defaultConfigEnv; | ||
if (configEnvDir) { | ||
@@ -37,0 +59,0 @@ if (fs.existsSync(path.join(this.configDir, configEnvDir))) { |
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
36532
648