Skip to content

Commit 9502bf5

Browse files
authored
Ignore files in deps dir when resolving wit packages (#1061)
* fix: ignore files in deps dir * run cargo fmt * improve comment and revert .gitignore * test: files in deps folder are ignored
1 parent 7f01895 commit 9502bf5

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ publish
66
*.wasm
77
*.wat
88
test.config
9+

crates/wit-parser/src/resolve.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ impl Resolve {
112112
for dep in path.read_dir().context("failed to read directory")? {
113113
let dep = dep.context("failed to read directory iterator")?;
114114
let path = dep.path();
115+
116+
// Files in deps dir are ignored for now to avoid accidentally
117+
// including things like `.DS_Store` files in the call below to
118+
// `parse_dir`.
119+
if path.is_file() {
120+
continue;
121+
}
122+
115123
let pkg = UnresolvedPackage::parse_dir(&path)
116124
.with_context(|| format!("failed to parse package: {}", path.display()))?;
117125
let prev = ret.insert(pkg.name.clone(), pkg);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package foo:bar
2+
interface types {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this file should be ignored by the parser
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package foo:foo
2+
3+
world foo {
4+
import foo:bar/types
5+
}

0 commit comments

Comments
 (0)