Comparing version 3.3.9 to 3.3.10
@@ -7,18 +7,21 @@ // config.js (c) 2010-2022 Loren West and other contributors | ||
// Dependencies | ||
var DeferredConfig = require('../defer').DeferredConfig, | ||
RawConfig = require('../raw').RawConfig, | ||
Parser = require('../parser'), | ||
Utils = require('util'), | ||
Path = require('path'), | ||
FileSystem = require('fs'); | ||
const DeferredConfig = require('../defer').DeferredConfig; | ||
const RawConfig = require('../raw').RawConfig; | ||
let Parser = require('../parser'); | ||
const Utils = require('util'); | ||
const Path = require('path'); | ||
const FileSystem = require('fs'); | ||
// Static members | ||
var DEFAULT_CLONE_DEPTH = 20, | ||
CONFIG_DIR, NODE_ENV, APP_INSTANCE, | ||
CONFIG_SKIP_GITCRYPT, NODE_ENV_VAR_NAME, | ||
NODE_CONFIG_PARSER, | ||
env = {}, | ||
configSources = [], // Configuration sources - array of {name, original, parsed} | ||
checkMutability = true, // Check for mutability/immutability on first get | ||
gitCryptTestRegex = /^.GITCRYPT/; // regular expression to test for gitcrypt files. | ||
const DEFAULT_CLONE_DEPTH = 20; | ||
let CONFIG_DIR; | ||
let NODE_ENV; | ||
let APP_INSTANCE; | ||
let CONFIG_SKIP_GITCRYPT; | ||
let NODE_ENV_VAR_NAME; | ||
let NODE_CONFIG_PARSER; | ||
const env = {}; | ||
const configSources = []; // Configuration sources - array of {name, original, parsed} | ||
let checkMutability = true; // Check for mutability/immutability on first get | ||
const gitCryptTestRegex = /^.GITCRYPT/; // regular expression to test for gitcrypt files. | ||
@@ -59,3 +62,3 @@ /** | ||
* <pre> | ||
* var CONFIG = require('config').customer; | ||
* const CONFIG = require('config').customer; | ||
* ... | ||
@@ -84,3 +87,3 @@ * newCustomer.creditLimit = CONFIG.initialCredit; | ||
* <pre> | ||
* var CONFIG = require('config'); | ||
* const CONFIG = require('config'); | ||
* </pre> | ||
@@ -93,5 +96,5 @@ * | ||
* <pre> | ||
* var CONFIG = require('config').customer; | ||
* const CONFIG = require('config').customer; | ||
* or | ||
* var CUSTOMER_CONFIG = require('config').customer; | ||
* const CUSTOMER_CONFIG = require('config').customer; | ||
* </pre> | ||
@@ -106,7 +109,7 @@ * | ||
*/ | ||
var Config = function() { | ||
var t = this; | ||
const Config = function() { | ||
const t = this; | ||
// Bind all utility functions to this | ||
for (var fnName in util) { | ||
for (const fnName in util) { | ||
if (typeof util[fnName] === 'function') { | ||
@@ -128,3 +131,3 @@ util[fnName] = util[fnName].bind(t); | ||
*/ | ||
var util = Config.prototype.util = {}; | ||
const util = Config.prototype.util = {}; | ||
@@ -140,7 +143,7 @@ /** | ||
*/ | ||
var getImpl= function(object, property) { | ||
var t = this, | ||
elems = Array.isArray(property) ? property : property.split('.'), | ||
name = elems[0], | ||
value = object[name]; | ||
const getImpl= function(object, property) { | ||
const t = this; | ||
const elems = Array.isArray(property) ? property : property.split('.'); | ||
const name = elems[0]; | ||
const value = object[name]; | ||
if (elems.length <= 1) { | ||
@@ -170,3 +173,3 @@ return value; | ||
Config.prototype.get = function(property) { | ||
if(property === null || property === undefined){ | ||
if(property === null || typeof property === "undefined"){ | ||
throw new Error("Calling config.get with null or undefined argument"); | ||
@@ -182,7 +185,7 @@ } | ||
} | ||
var t = this, | ||
value = getImpl(t, property); | ||
const t = this; | ||
const value = getImpl(t, property); | ||
// Produce an exception if the property doesn't exist | ||
if (value === undefined) { | ||
if (typeof value === "undefined") { | ||
throw new Error('Configuration property "' + property + '" is not defined'); | ||
@@ -199,3 +202,3 @@ } | ||
* <pre> | ||
* var config = require('config'); | ||
* const config = require('config'); | ||
* if (config.has('customer.dbName')) { | ||
@@ -212,7 +215,7 @@ * console.log('Customer database name: ' + config.customer.dbName); | ||
// While get() throws an exception for undefined input, has() is designed to test validity, so false is appropriate | ||
if(property === null || property === undefined){ | ||
if(property === null || typeof property === "undefined"){ | ||
return false; | ||
} | ||
var t = this; | ||
return (getImpl(t, property) !== undefined); | ||
const t = this; | ||
return typeof getImpl(t, property) !== "undefined"; | ||
}; | ||
@@ -233,3 +236,3 @@ | ||
* <pre> | ||
* var CONFIG = require("config"); | ||
* const CONFIG = require("config"); | ||
* CONFIG.util.setModuleDefaults("MyModule", { | ||
@@ -257,4 +260,4 @@ * templateName: "t-50", | ||
// Copy the properties into a new object | ||
var t = this, | ||
moduleConfig = util.cloneDeep(defaultProperties); | ||
const t = this; | ||
const moduleConfig = util.cloneDeep(defaultProperties); | ||
@@ -312,3 +315,3 @@ // Set module defaults into the first sources element | ||
* <pre> | ||
* var CONFIG = require('config'); | ||
* const CONFIG = require('config'); | ||
* ... | ||
@@ -368,4 +371,4 @@ * | ||
* <pre> | ||
* var config = require('config'); | ||
* var myObject = {hello:'world'}; | ||
* const config = require('config'); | ||
* const myObject = {hello:'world'}; | ||
* config.util.makeImmutable(myObject); | ||
@@ -387,3 +390,3 @@ * </pre> | ||
} | ||
var properties = null; | ||
let properties = null; | ||
@@ -408,5 +411,5 @@ // Backwards compatibility mode where property/value can be specified | ||
// Process each property | ||
for (var i = 0; i < properties.length; i++) { | ||
var propertyName = properties[i], | ||
value = object[propertyName]; | ||
for (let i = 0; i < properties.length; i++) { | ||
const propertyName = properties[i]; | ||
let value = object[propertyName]; | ||
@@ -469,3 +472,3 @@ if (value instanceof RawConfig) { | ||
util.getConfigSources = function() { | ||
var t = this; | ||
const t = this; | ||
return configSources.slice(0); | ||
@@ -489,3 +492,3 @@ }; | ||
util.getOption = function(options, optionName, defaultValue) { | ||
if (options !== undefined && options[optionName] !== undefined){ | ||
if (options !== undefined && typeof options[optionName] !== 'undefined'){ | ||
return options[optionName]; | ||
@@ -563,7 +566,7 @@ } else { | ||
// Initialize | ||
var t = this, | ||
config = {}; | ||
const t = this; | ||
const config = {}; | ||
// Specify variables that can be used to define the environment | ||
var node_env_var_names = ['NODE_CONFIG_ENV', 'NODE_ENV']; | ||
const node_env_var_names = ['NODE_CONFIG_ENV', 'NODE_ENV']; | ||
@@ -591,3 +594,3 @@ // Loop through the variables to try and set environment | ||
var dir = configDir || util.initParam('NODE_CONFIG_DIR', Path.join( process.cwd(), 'config') ); | ||
let dir = configDir || util.initParam('NODE_CONFIG_DIR', Path.join( process.cwd(), 'config') ); | ||
dir = _toAbsolutePath(dir); | ||
@@ -599,3 +602,3 @@ | ||
// This is for backward compatibility | ||
var runtimeFilename = util.initParam('NODE_CONFIG_RUNTIME_JSON', Path.join(dir , 'runtime.json') ); | ||
const runtimeFilename = util.initParam('NODE_CONFIG_RUNTIME_JSON', Path.join(dir , 'runtime.json') ); | ||
@@ -605,3 +608,3 @@ NODE_CONFIG_PARSER = util.initParam('NODE_CONFIG_PARSER'); | ||
try { | ||
var parserModule = Path.isAbsolute(NODE_CONFIG_PARSER) | ||
const parserModule = Path.isAbsolute(NODE_CONFIG_PARSER) | ||
? NODE_CONFIG_PARSER | ||
@@ -617,12 +620,11 @@ : Path.join(dir, NODE_CONFIG_PARSER); | ||
var HOST = util.initParam('HOST'); | ||
var HOSTNAME = util.initParam('HOSTNAME'); | ||
const HOST = util.initParam('HOST'); | ||
const HOSTNAME = util.initParam('HOSTNAME'); | ||
// Determine the host name from the OS module, $HOST, or $HOSTNAME | ||
// Remove any . appendages, and default to null if not set | ||
let hostName = HOST || HOSTNAME; | ||
try { | ||
var hostName = HOST || HOSTNAME; | ||
if (!hostName) { | ||
var OS = require('os'); | ||
const OS = require('os'); | ||
hostName = OS.hostname(); | ||
@@ -638,7 +640,7 @@ } | ||
// Read each file in turn | ||
var baseNames = ['default'].concat(NODE_ENV); | ||
const baseNames = ['default'].concat(NODE_ENV); | ||
// #236: Also add full hostname when they are different. | ||
if (hostName) { | ||
var firstDomain = hostName.split('.')[0]; | ||
const firstDomain = hostName.split('.')[0]; | ||
@@ -660,5 +662,5 @@ NODE_ENV.forEach(function(env) { | ||
var allowedFiles = {}; | ||
var resolutionIndex = 1; | ||
var extNames = Parser.getFilesOrder(); | ||
const allowedFiles = {}; | ||
let resolutionIndex = 1; | ||
const extNames = Parser.getFilesOrder(); | ||
baseNames.forEach(function(baseName) { | ||
@@ -673,5 +675,5 @@ extNames.forEach(function(extName) { | ||
var locatedFiles = util.locateMatchingFiles(dir, allowedFiles); | ||
const locatedFiles = util.locateMatchingFiles(dir, allowedFiles); | ||
locatedFiles.forEach(function(fullFilename) { | ||
var configObj = util.parseFile(fullFilename, options); | ||
const configObj = util.parseFile(fullFilename, options); | ||
if (configObj) { | ||
@@ -685,3 +687,3 @@ util.extendDeep(config, configObj); | ||
if (!configDir) { | ||
var envConfig = {}; | ||
let envConfig = {}; | ||
@@ -697,3 +699,3 @@ CONFIG_DIR = dir; | ||
util.extendDeep(config, envConfig); | ||
var skipConfigSources = util.getOption(options,'skipConfigSources', false); | ||
const skipConfigSources = util.getOption(options,'skipConfigSources', false); | ||
if (!skipConfigSources){ | ||
@@ -708,3 +710,3 @@ configSources.push({ | ||
// Override configurations from the --NODE_CONFIG command line | ||
var cmdLineConfig = util.getCmdLineArg('NODE_CONFIG'); | ||
let cmdLineConfig = util.getCmdLineArg('NODE_CONFIG'); | ||
if (cmdLineConfig) { | ||
@@ -717,3 +719,3 @@ try { | ||
util.extendDeep(config, cmdLineConfig); | ||
var skipConfigSources = util.getOption(options,'skipConfigSources', false); | ||
const skipConfigSources = util.getOption(options,'skipConfigSources', false); | ||
if (!skipConfigSources){ | ||
@@ -732,7 +734,7 @@ configSources.push({ | ||
// Override with environment variables if there is a custom-environment-variables.EXT mapping file | ||
var customEnvVars = util.getCustomEnvVars(dir, extNames); | ||
const customEnvVars = util.getCustomEnvVars(dir, extNames); | ||
util.extendDeep(config, customEnvVars); | ||
// Extend the original config with the contents of runtime.json (backwards compatibility) | ||
var runtimeJson = util.parseFile(runtimeFilename) || {}; | ||
const runtimeJson = util.parseFile(runtimeFilename) || {}; | ||
util.extendDeep(config, runtimeJson); | ||
@@ -779,3 +781,3 @@ | ||
util.resolveDeferredConfigs = function (config) { | ||
var deferred = []; | ||
const deferred = []; | ||
@@ -785,6 +787,6 @@ function _iterate (prop) { | ||
// We put the properties we are going to look it in an array to keep the order predictable | ||
var propsToSort = []; | ||
const propsToSort = []; | ||
// First step is to put the properties of interest in an array | ||
for (var property in prop) { | ||
for (const property in prop) { | ||
if (Object.hasOwnProperty.call(prop, property) && prop[property] != null) { | ||
@@ -800,3 +802,3 @@ propsToSort.push(property); | ||
} else if (prop[property].constructor === Array) { | ||
for (var i = 0; i < prop[property].length; i++) { | ||
for (let i = 0; i < prop[property].length; i++) { | ||
if (prop[property][i] instanceof DeferredConfig) { | ||
@@ -850,6 +852,6 @@ deferred.push(prop[property][i].prepare(config, prop[property], i)); | ||
util.parseFile = function(fullFilename, options) { | ||
var t = this, // Initialize | ||
configObject = null, | ||
fileContent = null, | ||
stat = null; | ||
const t = this; // Initialize | ||
let configObject = null; | ||
let fileContent = null; | ||
const stat = null; | ||
@@ -893,3 +895,3 @@ // Note that all methods here are the Sync versions. This is appropriate during | ||
// Keep track of this configuration sources, including empty ones, unless the skipConfigSources flag is set to true in the options | ||
var skipConfigSources = util.getOption(options,'skipConfigSources', false); | ||
const skipConfigSources = util.getOption(options,'skipConfigSources', false); | ||
if (typeof configObject === 'object' && !skipConfigSources) { | ||
@@ -933,3 +935,3 @@ configSources.push({ | ||
util.parseString = function (content, format) { | ||
var parser = Parser.getParser(format); | ||
const parser = Parser.getParser(format); | ||
if (typeof parser === 'function') { | ||
@@ -949,3 +951,3 @@ return parser(null, content); | ||
* <pre> | ||
* var CUST_CONFIG = require('config').Customer; | ||
* const CUST_CONFIG = require('config').Customer; | ||
* CUST_CONFIG.get(...) | ||
@@ -966,3 +968,3 @@ * </pre> | ||
// Recursion detection | ||
var t = this; | ||
const t = this; | ||
depth = (depth === null ? DEFAULT_CLONE_DEPTH : depth); | ||
@@ -975,3 +977,3 @@ if (depth < 0) { | ||
// because adding to toObject.__proto__ exposes the function in toObject | ||
for (var fnName in Config.prototype) { | ||
for (const fnName in Config.prototype) { | ||
if (!toObject[fnName]) { | ||
@@ -983,3 +985,3 @@ util.makeHidden(toObject, fnName, Config.prototype[fnName]); | ||
// Add prototypes to sub-objects | ||
for (var prop in toObject) { | ||
for (const prop in toObject) { | ||
if (util.isObject(toObject[prop])) { | ||
@@ -1021,6 +1023,6 @@ util.attachProtoDeep(toObject[prop], depth - 1); | ||
// and children have the same index | ||
var allParents = []; | ||
var allChildren = []; | ||
const allParents = []; | ||
const allChildren = []; | ||
var useBuffer = typeof Buffer != 'undefined'; | ||
const useBuffer = typeof Buffer !== 'undefined'; | ||
@@ -1042,3 +1044,3 @@ if (typeof circular === 'undefined') | ||
var child; | ||
let child; | ||
if (typeof parent != 'object') { | ||
@@ -1065,3 +1067,3 @@ return parent; | ||
if (circular) { | ||
var index = allParents.indexOf(parent); | ||
const index = allParents.indexOf(parent); | ||
@@ -1075,5 +1077,5 @@ if (index != -1) { | ||
for (var i in parent) { | ||
var propDescriptor = Object.getOwnPropertyDescriptor(parent,i); | ||
var hasGetter = ((propDescriptor !== undefined) && (propDescriptor.get !== undefined)); | ||
for (const i in parent) { | ||
const propDescriptor = Object.getOwnPropertyDescriptor(parent,i); | ||
const hasGetter = ((typeof propDescriptor !== 'undefined') && (typeof propDescriptor.get !== 'undefined')); | ||
@@ -1105,3 +1107,3 @@ if (hasGetter){ | ||
util.setPath = function (object, path, value) { | ||
var nextKey = null; | ||
let nextKey = null; | ||
if (value === null || path.length === 0) { | ||
@@ -1137,9 +1139,10 @@ return; | ||
util.substituteDeep = function (substitutionMap, variables) { | ||
var result = {}; | ||
const result = {}; | ||
function _substituteVars(map, vars, pathTo) { | ||
for (var prop in map) { | ||
var value = map[prop]; | ||
let parsedValue; | ||
for (const prop in map) { | ||
const value = map[prop]; | ||
if (typeof(value) === 'string') { // We found a leaf variable name | ||
if (vars[value] !== undefined && vars[value] !== '') { // if the vars provide a value set the value in the result map | ||
if (typeof vars[value] !== 'undefined' && vars[value] !== '') { // if the vars provide a value set the value in the result map | ||
util.setPath(result, pathTo.concat(prop), vars[value]); | ||
@@ -1149,5 +1152,6 @@ } | ||
else if (util.isObject(value)) { // work on the subtree, giving it a clone of the pathTo | ||
if ('__name' in value && '__format' in value && vars[value.__name] !== undefined && vars[value.__name] !== '') { | ||
if ('__name' in value && '__format' in value && typeof vars[value.__name] !== 'undefined' && vars[value.__name] !== '') { | ||
let parsedValue; | ||
try { | ||
var parsedValue = util.parseString(vars[value.__name], value.__format); | ||
parsedValue = util.parseString(vars[value.__name], value.__format); | ||
} catch(err) { | ||
@@ -1184,13 +1188,13 @@ err.message = '__format parser error in ' + value.__name + ': ' + err.message; | ||
util.getCustomEnvVars = function (configDir, extNames) { | ||
var result = {}; | ||
var resolutionIndex = 1; | ||
var allowedFiles = {}; | ||
const result = {}; | ||
let resolutionIndex = 1; | ||
const allowedFiles = {}; | ||
extNames.forEach(function (extName) { | ||
allowedFiles['custom-environment-variables' + '.' + extName] = resolutionIndex++; | ||
}); | ||
var locatedFiles = util.locateMatchingFiles(configDir, allowedFiles); | ||
const locatedFiles = util.locateMatchingFiles(configDir, allowedFiles); | ||
locatedFiles.forEach(function (fullFilename) { | ||
var configObj = util.parseFile(fullFilename); | ||
const configObj = util.parseFile(fullFilename); | ||
if (configObj) { | ||
var environmentSubstitutions = util.substituteDeep(configObj, process.env); | ||
const environmentSubstitutions = util.substituteDeep(configObj, process.env); | ||
util.extendDeep(result, environmentSubstitutions); | ||
@@ -1215,3 +1219,3 @@ } | ||
// Recursion detection | ||
var t = this; | ||
const t = this; | ||
depth = (depth === null ? DEFAULT_CLONE_DEPTH : depth); | ||
@@ -1241,3 +1245,3 @@ if (depth < 0) { | ||
// Compare the values | ||
for (var prop in object1) { | ||
for (const prop in object1) { | ||
@@ -1284,3 +1288,4 @@ // Call recursively if an object or array | ||
// Recursion detection | ||
var t = this, diff = {}; | ||
const t = this; | ||
const diff = {}; | ||
depth = (depth === null ? DEFAULT_CLONE_DEPTH : depth); | ||
@@ -1293,5 +1298,5 @@ if (depth < 0) { | ||
// from object 1. | ||
for (var parm in object2) { | ||
var value1 = object1[parm]; | ||
var value2 = object2[parm]; | ||
for (const parm in object2) { | ||
const value1 = object1[parm]; | ||
const value2 = object2[parm]; | ||
if (value1 && value2 && util.isObject(value2)) { | ||
@@ -1333,5 +1338,5 @@ if (!(util.equalsDeep(value1, value2))) { | ||
// Initialize | ||
var t = this; | ||
var vargs = Array.prototype.slice.call(arguments, 1); | ||
var depth = vargs.pop(); | ||
const t = this; | ||
const vargs = Array.prototype.slice.call(arguments, 1); | ||
let depth = vargs.pop(); | ||
if (typeof(depth) != 'number') { | ||
@@ -1351,7 +1356,7 @@ vargs.push(depth); | ||
// Cycle through each element of the object to merge from | ||
for (var prop in mergeFrom) { | ||
for (const prop in mergeFrom) { | ||
// save original value in deferred elements | ||
var fromIsDeferredFunc = mergeFrom[prop] instanceof DeferredConfig; | ||
var isDeferredFunc = mergeInto[prop] instanceof DeferredConfig; | ||
const fromIsDeferredFunc = mergeFrom[prop] instanceof DeferredConfig; | ||
const isDeferredFunc = mergeInto[prop] instanceof DeferredConfig; | ||
@@ -1432,6 +1437,6 @@ if (fromIsDeferredFunc && Object.hasOwnProperty.call(mergeInto, prop)) { | ||
util.initParam = function (paramName, defaultValue) { | ||
var t = this; | ||
const t = this; | ||
// Record and return the value | ||
var value = util.getCmdLineArg(paramName) || process.env[paramName] || defaultValue; | ||
const value = util.getCmdLineArg(paramName) || process.env[paramName] || defaultValue; | ||
env[paramName] = value; | ||
@@ -1457,6 +1462,6 @@ return value; | ||
util.getCmdLineArg = function (searchFor) { | ||
var cmdLineArgs = process.argv.slice(2, process.argv.length), | ||
argName = '--' + searchFor + '='; | ||
const cmdLineArgs = process.argv.slice(2, process.argv.length); | ||
const argName = '--' + searchFor + '='; | ||
for (var argvIt = 0; argvIt < cmdLineArgs.length; argvIt++) { | ||
for (let argvIt = 0; argvIt < cmdLineArgs.length; argvIt++) { | ||
if (cmdLineArgs[argvIt].indexOf(argName) === 0) { | ||
@@ -1495,3 +1500,3 @@ return cmdLineArgs[argvIt].substr(argName.length); | ||
util.getRegExpFlags = function (re) { | ||
var flags = ''; | ||
let flags = ''; | ||
re.global && (flags += 'g'); | ||
@@ -1515,5 +1520,5 @@ re.ignoreCase && (flags += 'i'); | ||
util.runStrictnessChecks = function (config) { | ||
var sources = config.util.getConfigSources(); | ||
const sources = config.util.getConfigSources(); | ||
var sourceFilenames = sources.map(function (src) { | ||
const sourceFilenames = sources.map(function (src) { | ||
return Path.basename(src.name); | ||
@@ -1524,3 +1529,3 @@ }); | ||
// Throw an exception if there's no explicit config file for NODE_ENV | ||
var anyFilesMatchEnv = sourceFilenames.some(function (filename) { | ||
const anyFilesMatchEnv = sourceFilenames.some(function (filename) { | ||
return filename.match(env); | ||
@@ -1539,3 +1544,3 @@ }); | ||
// Throw an exception if there's no explicit config file for NODE_APP_INSTANCE | ||
var anyFilesMatchInstance = sourceFilenames.some(function (filename) { | ||
const anyFilesMatchInstance = sourceFilenames.some(function (filename) { | ||
return filename.match(APP_INSTANCE); | ||
@@ -1548,5 +1553,5 @@ }); | ||
function _warnOrThrow (msg) { | ||
var beStrict = process.env.NODE_CONFIG_STRICT_MODE; | ||
var prefix = beStrict ? 'FATAL: ' : 'WARNING: '; | ||
var seeURL = 'See https://github.com/node-config/node-config/wiki/Strict-Mode'; | ||
const beStrict = process.env.NODE_CONFIG_STRICT_MODE; | ||
const prefix = beStrict ? 'FATAL: ' : 'WARNING: '; | ||
const seeURL = 'See https://github.com/node-config/node-config/wiki/Strict-Mode'; | ||
@@ -1573,3 +1578,3 @@ console.error(prefix+msg); | ||
// Instantiate and export the configuration | ||
var config = module.exports = new Config(); | ||
const config = module.exports = new Config(); | ||
@@ -1581,3 +1586,3 @@ // copy methods to util for backwards compatibility | ||
// Produce warnings if the configuration is empty | ||
var showWarnings = !(util.initParam('SUPPRESS_NO_CONFIG_WARNING')); | ||
const showWarnings = !(util.initParam('SUPPRESS_NO_CONFIG_WARNING')); | ||
if (showWarnings && Object.keys(config).length === 0) { | ||
@@ -1584,0 +1589,0 @@ console.error('WARNING: No configurations found in configuration directory:' +CONFIG_DIR); |
{ | ||
"name": "config", | ||
"version": "3.3.9", | ||
"version": "3.3.10", | ||
"main": "./lib/config.js", | ||
@@ -5,0 +5,0 @@ "description": "Configuration control for production node deployments", |
@@ -64,2 +64,3 @@ // External libraries are lazy-loaded only if these file types exist. | ||
lazy: true, | ||
ignore: ['(?:^|/)node_modules/', '.*(?<!\.ts)$'], | ||
transpileOnly: true, | ||
@@ -158,16 +159,10 @@ compilerOptions: { | ||
Parser.jsonParser = function(filename, content) { | ||
try { | ||
return JSON.parse(content); | ||
} | ||
catch (e) { | ||
// All JS Style comments will begin with /, so all JSON parse errors that | ||
// encountered a syntax error will complain about this character. | ||
if (e.name !== 'SyntaxError' || e.message.indexOf('Unexpected token /') !== 0) { | ||
throw e; | ||
} | ||
if (!JSON5) { | ||
JSON5 = require(JSON5_DEP); | ||
} | ||
/** | ||
* Default JSON parsing to JSON5 parser. | ||
* This is due to issues with removing supported comments. | ||
* More information can be found here: https://github.com/node-config/node-config/issues/715 | ||
*/ | ||
JSON5 = require(JSON5_DEP); | ||
return JSON5.parse(content); | ||
} | ||
}; | ||
@@ -202,5 +197,5 @@ | ||
if (typeof CSON.parseSync === 'function') { | ||
return CSON.parseSync(Parser.stripComments(content)); | ||
return CSON.parseSync(content); | ||
} | ||
return CSON.parse(Parser.stripComments(content)); | ||
return CSON.parse(content); | ||
}; | ||
@@ -232,3 +227,3 @@ | ||
Parser.stripComments = function(fileStr, stringRegex) { | ||
stringRegex = stringRegex || /(['"])(\\\1|.)+?\1/g; | ||
stringRegex = stringRegex || /"((?:[^"\\]|\\.)*)"/g; | ||
@@ -235,0 +230,0 @@ var uid = '_' + +new Date(), |
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
94030