fix(cli): skip mkdir when --out-file targets the current directory#11720
fix(cli): skip mkdir when --out-file targets the current directory#11720
Conversation
When `--out-file file.min.js` is used without a directory component,
`Path::parent()` returns an empty string. Calling `create_dir_all("")`
fails on Windows with EEXIST. Skip the directory creation when the
parent path is empty since the current directory always exists.
Closes #11717
Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
|
|
|
PR ReviewSummaryClean, well-scoped fix for Code QualityThe fix is correct and minimal. Both call sites where Potential IssuesNone identified. The guard correctly short-circuits before Minor ObservationIn if !output_dir.as_os_str().is_empty() && !output_dir.is_dir() {While in the second site (line 480), only the empty check is used: if !parent.as_os_str().is_empty() {
fs::create_dir_all(parent)?;
}The second site unconditionally calls PerformanceNo concerns. The added SecurityNo concerns. Test CoverageGood — the new test One suggestion: consider also testing the VerdictLGTM — clean fix, well-tested, addresses a real cross-platform issue. |
There was a problem hiding this comment.
Pull request overview
Fixes a Windows-specific CLI failure when --out-file is given without a directory component (e.g. file.min.js), where the computed parent path can be empty and create_dir_all("") fails.
Changes:
- Skip directory creation when the computed parent path is empty for
--out-fileand--out-diroutput paths. - Add a regression test covering
--out-file file.min.jswritten to the current directory (issue #11717).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/swc_cli_impl/src/commands/compile.rs |
Avoids calling create_dir_all with an empty parent path when emitting output files. |
crates/swc_cli_impl/tests/issues.rs |
Adds a regression test to ensure --out-file in the current directory succeeds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Binary Sizes
Commit: 2f6b10c |
When
--out-file file.min.jsis used without a directory component,Path::parent()returns an empty string. Callingcreate_dir_all("")fails on Windows with EEXIST. Skip the directory creation when the parent path is empty.Closes #11717
Generated with Claude Code