config-ninja
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -16,3 +16,3 @@ 'use strict'; | ||
*/ | ||
const readConfigFile = function (type, name, dir, configInFilename) { | ||
const readConfigFile = function (type, name, dir, configInFilename, ignoreMissing) { | ||
@@ -25,3 +25,5 @@ const filename = path.join(dir, `${name}${configInFilename ? '.config' : ''}.json`); | ||
} catch (err) { | ||
throw new Error(`Unable to read ${type} config "${name}" (${err.code}).`); | ||
if (!ignoreMissing) { | ||
throw new Error(`Unable to read ${type} config "${name}" (${err.code}).`); | ||
} | ||
} | ||
@@ -59,2 +61,3 @@ | ||
additionalMergeFiles: [], | ||
ignoreMissingAdditional: true, | ||
}, _options); | ||
@@ -104,3 +107,3 @@ | ||
addCfg = readConfigFile('additional', additionalMergeFile, dir, options.configInFilename); | ||
addCfg = readConfigFile('additional', additionalMergeFile, dir, options.configInFilename, options.ignoreMissingAdditional); | ||
addCfg = parseConfigJSON('additional', additionalMergeFile, addCfg); | ||
@@ -107,0 +110,0 @@ |
@@ -13,3 +13,3 @@ { | ||
"name": "config-ninja", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Environmental JSON config.", | ||
@@ -16,0 +16,0 @@ "keywords": [ |
@@ -48,6 +48,7 @@ # Config-Ninja | ||
| Property | Default | Description | | ||
|------------------------|---------|-------------| | ||
| configInFilename | true | Set false if you want to your config filenames to be in the format of `development.json` instead of the default `development.config.json`. | | ||
| additionalMergeFiles[] | | Specify a list of other filenames to merge into your config, if the files don't exist they will just be ignored. Properties in additional files will overwrite properties with the same name in your config. | | ||
| Property | Default | Description | | ||
|-------------------------|---------|-------------| | ||
| configInFilename | true | Set false if you want to your config filenames to be in the format of `development.json` instead of the default `development.config.json`. | | ||
| additionalMergeFiles[] | | Specify a list of other filenames to merge into your config, if the files don't exist they will just be ignored. Properties in additional files will overwrite properties with the same name in your config. | | ||
| ignoreMissingAdditional | true | By default we don't throw an error if an additional config file is missing. | | ||
@@ -54,0 +55,0 @@ ## Reserved Property Names |
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
8896
132
78