diff --git a/lerna.json b/lerna.json index 5fdbef6d..7cae3e3b 100644 --- a/lerna.json +++ b/lerna.json @@ -2,5 +2,5 @@ "packages": [ "packages/*" ], - "version": "6.0.0" + "version": "6.0.1-alpha.1" } diff --git a/packages/convict-format-with-moment/package.json b/packages/convict-format-with-moment/package.json index b28acc71..39d16d1b 100644 --- a/packages/convict-format-with-moment/package.json +++ b/packages/convict-format-with-moment/package.json @@ -9,7 +9,7 @@ "timestamp", "moment" ], - "version": "6.0.0", + "version": "6.0.1-alpha.1", "license": "Apache-2.0", "homepage": "https://github.com/mozilla/node-convict", "repository": { @@ -26,5 +26,6 @@ ], "dependencies": { "moment": "^2.24.0" - } + }, + "gitHead": "d345d374498df65397206426d3753fcf5f9701e2" } diff --git a/packages/convict-format-with-validator/package.json b/packages/convict-format-with-validator/package.json index 4d669d58..145b6ab7 100644 --- a/packages/convict-format-with-validator/package.json +++ b/packages/convict-format-with-validator/package.json @@ -10,7 +10,7 @@ "url", "validator" ], - "version": "6.0.0", + "version": "6.0.1-alpha.1", "license": "Apache-2.0", "homepage": "https://github.com/mozilla/node-convict", "repository": { @@ -27,5 +27,6 @@ ], "dependencies": { "validator": "^11.1.0" - } + }, + "gitHead": "d345d374498df65397206426d3753fcf5f9701e2" } diff --git a/packages/convict/package.json b/packages/convict/package.json index 0688c140..12f7a286 100644 --- a/packages/convict/package.json +++ b/packages/convict/package.json @@ -1,6 +1,6 @@ { "author": "Lloyd Hilaiel (http://lloyd.io)", - "name": "convict", + "name": "@atlassian/convict", "description": "Featureful configuration management library for Node.js (nested structure, schema validation, etc.)", "keywords": [ "configuration", @@ -17,7 +17,7 @@ "yaml", "toml" ], - "version": "6.0.0", + "version": "6.0.1-alpha.1", "license": "Apache-2.0", "homepage": "https://github.com/mozilla/node-convict", "repository": { @@ -35,5 +35,6 @@ "dependencies": { "lodash.clonedeep": "^4.5.0", "yargs-parser": "^18.1.3" - } + }, + "gitHead": "d345d374498df65397206426d3753fcf5f9701e2" } diff --git a/packages/convict/src/main.js b/packages/convict/src/main.js index 5aad9325..32b0d385 100644 --- a/packages/convict/src/main.js +++ b/packages/convict/src/main.js @@ -73,7 +73,7 @@ const ALLOWED_OPTION_STRICT = 'strict' const ALLOWED_OPTION_WARN = 'warn' function flatten(obj, useProperties) { - const stack = Object.keys(obj) + const stack = Object.keys(obj).map(k => [k]) let key const entries = [] @@ -85,9 +85,9 @@ function flatten(obj, useProperties) { if (useProperties) { if ('_cvtProperties' in val) { val = val._cvtProperties - key = key + '._cvtProperties' + key.push('_cvtProperties') } else { - entries.push([key, val]) + entries.push([key.join('.'), val]) continue } } @@ -96,12 +96,12 @@ function flatten(obj, useProperties) { // Don't filter out empty objects if (subkeys.length > 0) { subkeys.forEach(function(subkey) { - stack.push(key + '.' + subkey) + stack.push(key.concat([subkey])) }) continue } } - entries.push([key, val]) + entries.push([key.join('.'), val]) } const flattened = {} @@ -431,7 +431,7 @@ function loadFile(path) { function walk(obj, path, initializeMissing) { if (path) { - const ar = path.split('.') + const ar = Array.isArray(path) ? cloneDeep(path) : path.split('.') while (ar.length) { const k = ar.shift() if (initializeMissing && obj[k] == null) { diff --git a/packages/convict/test/cases/nested_dotpath.js b/packages/convict/test/cases/nested_dotpath.js new file mode 100644 index 00000000..82eec5ba --- /dev/null +++ b/packages/convict/test/cases/nested_dotpath.js @@ -0,0 +1,5 @@ +'use strict' + +exports.conf = { + dynamic: {format: Object, default: null} +} diff --git a/packages/convict/test/cases/nested_dotpath.json b/packages/convict/test/cases/nested_dotpath.json new file mode 100644 index 00000000..8b94b4bb --- /dev/null +++ b/packages/convict/test/cases/nested_dotpath.json @@ -0,0 +1,5 @@ +{ + "dynamic": { + "dot.path": {} + } +} diff --git a/packages/convict/test/cases/nested_dotpath.out b/packages/convict/test/cases/nested_dotpath.out new file mode 100644 index 00000000..8b94b4bb --- /dev/null +++ b/packages/convict/test/cases/nested_dotpath.out @@ -0,0 +1,5 @@ +{ + "dynamic": { + "dot.path": {} + } +}