-
Notifications
You must be signed in to change notification settings - Fork 7
chore: adjust merge logic #175
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,10 +64,30 @@ export default function (originOpts: any = {}) { | |
|
|
||
| let config = getConfig(); | ||
|
|
||
| // Merge `jest.config.js` | ||
| const userJestConfigFile = path.resolve(cwd, 'jest.config.js'); | ||
| if (fs.existsSync(userJestConfigFile)) { | ||
| const { setupFiles = [], setupFilesAfterEnv = [], ...restConfig } = require(userJestConfigFile); | ||
| // Merge Jest config file (support .js, .ts, .json) | ||
| let userJestConfigFile = null; | ||
| const possibleConfigFiles = [ | ||
| 'jest.config.js', | ||
| 'jest.config.ts', | ||
| 'jest.config.json', | ||
| '.jest.config.js', | ||
| '.jest.config.ts', | ||
| '.jest.config.json', | ||
| ]; | ||
|
|
||
| for (let i = 0; i < possibleConfigFiles.length; i++) { | ||
| const configPath = path.resolve(cwd, possibleConfigFiles[i]); | ||
| if (fs.existsSync(configPath)) { | ||
| userJestConfigFile = configPath; | ||
| break; | ||
| } | ||
| } | ||
|
Comment on lines
+68
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| if (userJestConfigFile) { | ||
| let userConfig = require(userJestConfigFile); | ||
| userConfig = userConfig.default || userConfig; | ||
|
|
||
| const { setupFiles = [], setupFilesAfterEnv = [], ...restConfig } = userConfig; | ||
| config = { | ||
| ...config, | ||
| ...restConfig, | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: react-component/rc-test
Length of output: 1386
🏁 Script executed:
Repository: react-component/rc-test
Length of output: 141
🏁 Script executed:
Repository: react-component/rc-test
Length of output: 1174
🏁 Script executed:
Repository: react-component/rc-test
Length of output: 81
🏁 Script executed:
# 获取完整的 package.json cat package.jsonRepository: react-component/rc-test
Length of output: 2062
🏁 Script executed:
# 检查 bin/rc-test.js 是否有 TypeScript 加载器注册 cat bin/rc-test.jsRepository: react-component/rc-test
Length of output: 438
🏁 Script executed:
Repository: react-component/rc-test
Length of output: 89
🏁 Script executed:
Repository: react-component/rc-test
Length of output: 138
🏁 Script executed:
Repository: react-component/rc-test
Length of output: 141
处理 TypeScript 配置文件的加载支持。
代码在第 70 和 74 行列出了
jest.config.ts和.jest.config.ts作为可能的配置文件,但第 87 行使用require()加载配置文件。项目的依赖中不包含 ts-node、@swc-node/register、tsx 或其他 TypeScript 加载器,因此当用户提供 TypeScript 配置文件时,require()会失败。建议:
.ts文件添加错误处理并改用.js配置🤖 Prompt for AI Agents