Skip to content

Commit c966483

Browse files
committed
docs: adds notes about $hidden directive
1 parent 6e3797f commit c966483

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

app-config-extensions/src/index.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,42 @@ describe('$hidden directive', () => {
253253
$hidden: {
254254
foo: 42,
255255
},
256+
baz: {
257+
$hidden: 44,
258+
},
256259
foo: {
257260
$extendsSelf: '$hidden.foo',
258261
},
262+
bar: {
263+
$extendsSelf: 'baz.$hidden',
264+
},
259265
});
260266

261267
expect(await source.readToJSON([extendsSelfDirective(), hiddenDirective()])).toEqual({
268+
baz: {},
262269
foo: 42,
270+
bar: 44,
271+
});
272+
});
273+
274+
it('references hidden property and processes it', async () => {
275+
process.env.FOO = 'bar';
276+
277+
const source = new LiteralSource({
278+
$hidden: {
279+
foo: {
280+
$envVar: 'FOO',
281+
},
282+
},
283+
foo: {
284+
$extendsSelf: '$hidden.foo',
285+
},
286+
});
287+
288+
expect(
289+
await source.readToJSON([extendsSelfDirective(), hiddenDirective(), envVarDirective()]),
290+
).toEqual({
291+
foo: 'bar',
263292
});
264293
});
265294
});

docs/guide/intro/extensions.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,25 @@ $if:
181181
$else: bar
182182
```
183183

184+
## The `$hidden` Directive
185+
186+
You can use `$hidden` anywhere - the values underneath it are not processed directly.
187+
This is useful for shared values.
188+
189+
```yaml
190+
$hidden:
191+
foo: 42
192+
193+
bar:
194+
baz:
195+
$extendsSelf: '$hidden.foo'
196+
197+
qux:
198+
$extendsSelf: '$hidden.foo'
199+
```
200+
201+
This results in `{ bar: { baz: 42 }, qux: 42 }`.
202+
184203
## The `$timestamp` Directive
185204

186205
Allows injecting the current date and time into configuration. While this option is useful,

0 commit comments

Comments
 (0)