Skip to content

Commit 85cc2bd

Browse files
authoredSep 17, 2024
fix(cli): Exclude non-files from get_files_list (#9560)
**Description:** `get_files_list` does not check if a path with the `extensions` is really a file. **Related issue:** - Closes #9559
1 parent 9dd8f6f commit 85cc2bd

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
 

‎.changeset/weak-papayas-deliver.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_core: patch
3+
swc_cli_impl: patch
4+
---
5+
6+
fix(cli): Exclude non-files from get_files_list

‎crates/swc_cli_impl/src/commands/compile.rs

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fn get_files_list(
146146
.into_iter()
147147
.filter_map(|e| e.ok())
148148
.map(|e| e.into_path())
149+
.filter(|e| e.is_file())
149150
.filter(|e| {
150151
extensions
151152
.iter()

‎crates/swc_cli_impl/tests/issues.rs

+14
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,20 @@ fn issue_8667_1() -> Result<()> {
144144
Ok(())
145145
}
146146

147+
#[test]
148+
fn issue_9559() -> Result<()> {
149+
let sandbox = TempDir::new()?;
150+
fs::write(sandbox.path().join("index.ts"), r"console.log('Hello')")?;
151+
fs::create_dir(sandbox.path().join("chart.js"))?;
152+
153+
let mut cmd = cli()?;
154+
cmd.current_dir(&sandbox).arg("compile").arg(sandbox.path());
155+
156+
cmd.assert().success();
157+
158+
Ok(())
159+
}
160+
147161
/// ln -s $a $b
148162
fn symlink(a: &Path, b: &Path) {
149163
#[cfg(unix)]

0 commit comments

Comments
 (0)