Skip to content

Commit

Permalink
Fix for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed May 7, 2024
1 parent f13feb4 commit fe34901
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/turborepo-lib/src/package_changes_watcher.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{cell::RefCell, collections::HashSet, ops::DerefMut, path::PathBuf};
use std::{cell::RefCell, collections::HashSet, ops::DerefMut};

use ignore::gitignore::Gitignore;
use notify::Event;
Expand Down Expand Up @@ -56,7 +56,8 @@ impl PackageChangesWatcher {

enum ChangedFiles {
All,
Some(Trie<PathBuf, ()>),
// Trie doesn't support PathBuf as a key on Windows, so we need to use `String`
Some(Trie<String, ()>),
}

impl ChangedFiles {
Expand Down Expand Up @@ -189,7 +190,9 @@ impl Subscriber {
self.changed_files.lock().await.borrow_mut().deref_mut()
{
for path in paths {
trie.insert(path, ());
if let Some(path) = path.to_str() {
trie.insert(path.to_string(), ());
}
}
}
}
Expand Down Expand Up @@ -264,15 +267,15 @@ impl Subscriber {
};

let gitignore_path = self.repo_root.join_component(".gitignore");
if trie.get(gitignore_path.as_std_path()).is_some() {
if trie.get(gitignore_path.as_str()).is_some() {
let (new_root_gitignore, _) = Gitignore::new(&gitignore_path);
root_gitignore = new_root_gitignore;
}

let changed_files: HashSet<_> = trie
.keys()
.filter_map(|p| {
let p = AbsoluteSystemPathBuf::try_from(p.as_path()).ok()?;
let p = AbsoluteSystemPathBuf::new(p).ok()?;
self.repo_root.anchor(p).ok()
})
.filter(|p| {
Expand Down

0 comments on commit fe34901

Please sign in to comment.