fix(core): building project graphs is broken for Windows (#15257)
This commit is contained in:
parent
15019cfcec
commit
0b30f1fce7
@ -3,6 +3,7 @@
|
|||||||
use crossbeam_channel::unbounded;
|
use crossbeam_channel::unbounded;
|
||||||
use ignore::WalkBuilder;
|
use ignore::WalkBuilder;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::path::Path;
|
||||||
use std::thread::{self, available_parallelism};
|
use std::thread::{self, available_parallelism};
|
||||||
use xxhash_rust::xxh3;
|
use xxhash_rust::xxh3;
|
||||||
|
|
||||||
@ -28,12 +29,12 @@ fn hash_file(file: String) -> Option<FileData> {
|
|||||||
#[napi]
|
#[napi]
|
||||||
fn hash_files(workspace_root: String) -> HashMap<String, String> {
|
fn hash_files(workspace_root: String) -> HashMap<String, String> {
|
||||||
let mut walker = WalkBuilder::new(&workspace_root);
|
let mut walker = WalkBuilder::new(&workspace_root);
|
||||||
let workspace_root = workspace_root + "/";
|
let workspace_root = Path::new(&workspace_root);
|
||||||
walker.add_ignore(workspace_root.clone() + ".nxignore");
|
walker.add_ignore(workspace_root.join(".nxignore"));
|
||||||
|
|
||||||
let git_folder = workspace_root.clone() + ".git";
|
let git_folder = workspace_root.join(".git");
|
||||||
// We should make sure to always ignore node_modules
|
// We should make sure to always ignore node_modules
|
||||||
let node_folder = workspace_root.clone() + "node_modules";
|
let node_folder = workspace_root.join("node_modules");
|
||||||
walker.filter_entry(move |entry| {
|
walker.filter_entry(move |entry| {
|
||||||
!(entry.path().starts_with(&git_folder) || entry.path().starts_with(&node_folder))
|
!(entry.path().starts_with(&git_folder) || entry.path().starts_with(&node_folder))
|
||||||
});
|
});
|
||||||
@ -68,11 +69,18 @@ fn hash_files(workspace_root: String) -> HashMap<String, String> {
|
|||||||
return Continue;
|
return Continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let file_path = dir_entry.path().display().to_string();
|
let Ok(file_path) = dir_entry.path().strip_prefix(&workspace_root) else {
|
||||||
let Some(file_path) = file_path.strip_prefix(&workspace_root) else {
|
|
||||||
return Continue;
|
return Continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let Some(file_path) = file_path.to_str() else {
|
||||||
|
return Continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
// convert back-slashes in Windows paths, since the js expects only forward-slash path separators
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
let file_path = file_path.replace('\\', "/");
|
||||||
|
|
||||||
tx.send((file_path.to_string(), content)).ok();
|
tx.send((file_path.to_string(), content)).ok();
|
||||||
|
|
||||||
Continue
|
Continue
|
||||||
@ -162,6 +170,3 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user