Skip to content

Commit

Permalink
Ignore files in deps dir when resolving wit packages (#1061)
Browse files Browse the repository at this point in the history
* fix: ignore files in deps dir

* run cargo fmt

* improve comment and revert .gitignore

* test: files in deps folder are ignored
  • Loading branch information
cardoso authored Jun 13, 2023
1 parent 7f01895 commit 9502bf5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ publish
*.wasm
*.wat
test.config

8 changes: 8 additions & 0 deletions crates/wit-parser/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ impl Resolve {
for dep in path.read_dir().context("failed to read directory")? {
let dep = dep.context("failed to read directory iterator")?;
let path = dep.path();

// Files in deps dir are ignored for now to avoid accidentally
// including things like `.DS_Store` files in the call below to
// `parse_dir`.
if path.is_file() {
continue;
}

let pkg = UnresolvedPackage::parse_dir(&path)
.with_context(|| format!("failed to parse package: {}", path.display()))?;
let prev = ret.insert(pkg.name.clone(), pkg);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package foo:bar
interface types {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this file should be ignored by the parser
5 changes: 5 additions & 0 deletions crates/wit-parser/tests/ui/ignore-files-deps/world.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package foo:foo

world foo {
import foo:bar/types
}

0 comments on commit 9502bf5

Please sign in to comment.