From a3729539855212d99ceb4a7ddb6bc98f6b84e7da Mon Sep 17 00:00:00 2001 From: Ryan Block Date: Mon, 23 Oct 2023 11:00:52 -0700 Subject: [PATCH] Add ability for unknown function-level configuration settings to be arrays / vectors --- changelog.md | 8 ++++++++ src/config/_upsert.js | 2 +- test/unit/src/config/_upsert-test.js | 25 ++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index afbe01ce..e9f4e992 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,14 @@ --- +## [3.6.2] 2023-10-23 + +### Added + +- Added ability for unknown function-level configuration settings to be arrays / vectors + +--- + ## [3.6.1] 2023-08-15 ### Fixed diff --git a/src/config/_upsert.js b/src/config/_upsert.js index 5ceee91d..7d3efd79 100644 --- a/src/config/_upsert.js +++ b/src/config/_upsert.js @@ -60,7 +60,7 @@ module.exports = function upsertProps (config, newConfig) { policies = policies.concat(value) } else { - props[name] = value[0] + props[name] = value.length === 1 ? value[0] : value } } diff --git a/test/unit/src/config/_upsert-test.js b/test/unit/src/config/_upsert-test.js index f6311c4f..d6b3b00b 100644 --- a/test/unit/src/config/_upsert-test.js +++ b/test/unit/src/config/_upsert-test.js @@ -453,12 +453,31 @@ runtime python }) test('Individual setting upsert: something unknown', t => { - t.plan(2) - let value = 'mysterious' + t.plan(6) + let result, value + + value = 'mysterious' let { aws: idk } = parse(`@aws idk ${value} `) - let result = upsert(defaults, idk) + result = upsert(defaults, idk) t.notOk(defaults.idk, 'Testing property not already present in the default') t.equal(result.idk, value, 'Properly upserted unknown setting') + + value = [ 'foo', 'bar' ] + let { aws: arr } = parse(`@aws +arr + ${value[0]} + ${value[1]} +`) + result = upsert(defaults, arr) + t.notOk(defaults.arr, 'Testing property not already present in the default') + t.deepEqual(result.arr, value, 'Properly upserted unknown array setting') + + let { aws: inlineArr } = parse(`@aws +arr ${value[0]} ${value[1]} +`) + result = upsert(defaults, inlineArr) + t.notOk(defaults.arr, 'Testing property not already present in the default') + t.deepEqual(result.arr, value, 'Properly upserted unknown inline array setting') })