Skip to content

Commit b87265a

Browse files
fix(config): read values from validated config (#203)
* fix(config): read values from validated config * chore: changeset
1 parent 6aa1320 commit b87265a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.changeset/rotten-impalas-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rnef/config': patch
3+
---
4+
5+
Read validated config values to properly include default values.

packages/config/src/lib/config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as fs from 'node:fs';
22
import { createRequire } from 'node:module';
33
import * as path from 'node:path';
44
import { color, logger } from '@rnef/tools';
5+
import type { ValidationError } from 'joi';
56
import { ConfigTypeSchema } from './schema.js';
67
import { formatValidationError } from './utils.js';
78

@@ -102,7 +103,12 @@ export async function getConfig(
102103
// eslint-disable-next-line prefer-const
103104
let { config, filePathWithExt } = await importUp(dir, 'rnef.config');
104105

105-
const { error } = ConfigTypeSchema.validate(config);
106+
const { error, value: validatedConfig } = ConfigTypeSchema.validate(
107+
config
108+
) as {
109+
error: ValidationError | null;
110+
value: ConfigType;
111+
};
106112

107113
if (error) {
108114
logger.error(
@@ -121,7 +127,7 @@ export async function getConfig(
121127
get reactNativeVersion() {
122128
return getReactNativeVersion(config.root || dir);
123129
},
124-
...config,
130+
...validatedConfig,
125131
};
126132

127133
const api = {

0 commit comments

Comments
 (0)