-
Notifications
You must be signed in to change notification settings - Fork 70
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
fix: entry support sub paths #1547
Conversation
Walkthrough此次更改涉及多处文件的重构和增强,包括引入新的辅助函数以改善文件写入逻辑、增加对模块的测试覆盖、扩展配置文件以支持新源文件、添加接口以增强类型定义、以及改进构建结果解析功能以处理嵌套目录。这些更改共同提升了代码的可维护性和测试的全面性。 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Config
participant FileSystem
participant TestUtils
User->>Config: Add new entry for "hoo/hoo"
Config->>FileSystem: Update configuration file
User->>TestUtils: Run tests
TestUtils->>FileSystem: Verify module inclusion
FileSystem-->>TestUtils: Return results
TestUtils->>User: Report test outcomes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- crates/mako/src/generate.rs (4 hunks)
- e2e/fixtures/config.entry/expect.js (1 hunks)
- e2e/fixtures/config.entry/mako.config.json (1 hunks)
- e2e/fixtures/config.entry/src/hoo.ts (1 hunks)
- packages/mako/binding.d.ts (1 hunks)
- scripts/test-utils.js (1 hunks)
Files skipped from review due to trivial changes (1)
- e2e/fixtures/config.entry/src/hoo.ts
Additional comments not posted (16)
e2e/fixtures/config.entry/mako.config.json (2)
4-4
: 代码更改通过!该行正确地添加了一个新的条目
foo
,与现有结构一致。代码更改已通过。
5-5
: 代码更改通过!该行正确地添加了一个新的条目
hoo/hoo
,并保持了 JSON 结构。代码更改已通过。
e2e/fixtures/config.entry/expect.js (1)
11-11
: 代码更改通过!该行正确地添加了一个断言,以确保
names
数组中存在hoo/hoo.js
。代码更改已通过。
scripts/test-utils.js (12)
10-10
: 代码更改通过!该行正确地初始化了变量
fileOrDir
以处理文件和目录。代码更改已通过。
11-11
: 代码更改通过!该行正确地检查了路径是否为文件。
代码更改已通过。
12-12
: 代码更改通过!该行正确地读取了文件内容。
代码更改已通过。
13-13
: 代码更改通过!该行正确地结束了 if 代码块。
代码更改已通过。
14-14
: 代码更改通过!该行正确地读取了目录的内容。
代码更改已通过。
15-15
: 代码更改通过!该行正确地遍历了目录中的每个文件。
代码更改已通过。
16-16
: 代码更改通过!该行正确地构建了每个子文件的路径。
代码更改已通过。
17-17
: 代码更改通过!该行正确地读取了每个子文件的内容。
代码更改已通过。
18-18
: 代码更改通过!该行正确地指定了读取子文件的编码。
代码更改已通过。
19-19
: 代码更改通过!该行正确地结束了 readFileSync 调用。
代码更改已通过。
20-20
: 代码更改通过!该行正确地结束了 forEach 循环。
代码更改已通过。
21-21
: 代码更改通过!该行正确地结束了 else 代码块。
代码更改已通过。
packages/mako/binding.d.ts (1)
6-9
: 新增的TransformOutput
接口定义正确接口定义包含必需的
code
属性和可选的map
属性,符合类型安全和清晰度的要求。代码更改已批准。
fn write_to_file(path: &str, content: &Vec<u8>) -> std::io::Result<()> { | ||
if let Some(parent) = std::path::Path::new(path).parent() { | ||
if !parent.exists() { | ||
fs::create_dir_all(parent)?; | ||
} | ||
} | ||
fs::write(path, content) |
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.
改进错误处理和日志记录
write_to_file
函数正确处理了目录创建和文件写入,但可以通过以下方式进一步改进:
- 添加目录创建和文件写入的错误处理。
- 添加文件写入成功的日志记录。
建议应用以下 diff 进行改进:
fn write_to_file(path: &str, content: &Vec<u8>) -> std::io::Result<()> {
if let Some(parent) = std::path::Path::new(path).parent() {
if !parent.exists() {
fs::create_dir_all(parent).map_err(|e| {
+ eprintln!("Failed to create directory {}: {}", parent.display(), e);
e
})?;
}
}
- fs::write(path, content)
+ fs::write(path, content).map_err(|e| {
+ eprintln!("Failed to write file {}: {}", path, e);
+ e
+ })?;
+ println!("Successfully wrote file {}", path);
+ Ok(())
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
fn write_to_file(path: &str, content: &Vec<u8>) -> std::io::Result<()> { | |
if let Some(parent) = std::path::Path::new(path).parent() { | |
if !parent.exists() { | |
fs::create_dir_all(parent)?; | |
} | |
} | |
fs::write(path, content) | |
fn write_to_file(path: &str, content: &Vec<u8>) -> std::io::Result<()> { | |
if let Some(parent) = std::path::Path::new(path).parent() { | |
if !parent.exists() { | |
fs::create_dir_all(parent).map_err(|e| { | |
eprintln!("Failed to create directory {}: {}", parent.display(), e); | |
e | |
})?; | |
} | |
} | |
fs::write(path, content).map_err(|e| { | |
eprintln!("Failed to write file {}: {}", path, e); | |
e | |
})?; | |
println!("Successfully wrote file {}", path); | |
Ok(()) | |
} |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1547 +/- ##
==========================================
- Coverage 60.97% 60.89% -0.08%
==========================================
Files 126 126
Lines 15091 15125 +34
==========================================
+ Hits 9201 9210 +9
- Misses 5890 5915 +25 ☔ View full report in Codecov by Sentry. |
what about |
it's work. |
e.g.
需求方:式夏
Summary by CodeRabbit
新功能
"hoo/hoo"
至配置文件,扩展了构建过程的功能。hoo.ts
文件,提供简单的日志记录功能。TransformOutput
接口,提升了类型安全性和清晰度。改进
hoo/hoo.js
在配置中被正确包含。