-
-
Notifications
You must be signed in to change notification settings - Fork 19
feat: export mergeProjectConfig method
#773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import { | |
| mergeRsbuildConfig, | ||
| } from '@rsbuild/core'; | ||
| import { dirname, isAbsolute, join, resolve } from 'pathe'; | ||
| import type { NormalizedConfig, RstestConfig } from './types'; | ||
| import type { NormalizedConfig, ProjectConfig, RstestConfig } from './types'; | ||
| import { | ||
| castArray, | ||
| color, | ||
|
|
@@ -76,6 +76,12 @@ export async function loadConfig({ | |
| return { content: content as RstestConfig, filePath: configFilePath }; | ||
| } | ||
|
|
||
| export const mergeProjectConfig = ( | ||
| ...configs: ProjectConfig[] | ||
| ): ProjectConfig => { | ||
| return mergeRstestConfig(...configs) as ProjectConfig; | ||
| }; | ||
|
Comment on lines
+79
to
+83
|
||
|
|
||
| export const mergeRstestConfig = (...configs: RstestConfig[]): RstestConfig => { | ||
| return configs.reduce<RstestConfig>((result, config) => { | ||
| const merged = mergeRsbuildConfig(result, { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type cast from
RstestConfigtoProjectConfigis potentially unsafe. SincemergeRstestConfigcan include properties likereporters,pool,coverage, etc. that are explicitly omitted fromProjectConfig, the returned object may contain properties that violate theProjectConfigtype contract. Consider implementing a proper merge function that only handlesProjectConfigproperties, or add runtime filtering to remove the omitted properties before returning.