Skip to content

Commit

Permalink
fix nested Config.array (Effect-TS#3499)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Aug 23, 2024
1 parent f960bf4 commit 46a575f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tricky-mails-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

fix nested Config.array, by ensuring path patches aren't applied twice in sequences
2 changes: 1 addition & 1 deletion packages/effect/src/internal/configProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ const fromFlatLoop = <A>(
core.flatMap((indices) => {
if (indices.length === 0) {
return core.suspend(() =>
core.map(fromFlatLoop(flat, patchedPrefix, op.config, true), Arr.of)
core.map(fromFlatLoop(flat, prefix, op.config, true), Arr.of)
) as unknown as Effect.Effect<Array<A>, ConfigError.ConfigError>
}
return pipe(
Expand Down
12 changes: 12 additions & 0 deletions packages/effect/test/Config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,4 +557,16 @@ describe("Config", () => {
))
assert.strictEqual(result, "value")
})

it("array nested", () => {
const result = Config.array(Config.number(), "ARRAY").pipe(
Effect.withConfigProvider(
ConfigProvider.fromMap(new Map([["NESTED.ARRAY", "1,2,3"]])).pipe(
ConfigProvider.nested("NESTED")
)
),
Effect.runSync
)
assert.deepStrictEqual(result, [1, 2, 3])
})
})

0 comments on commit 46a575f

Please sign in to comment.