use std::path::Path;
pub fn link_repository_dependencies(root: &Path) {
let link = root.join("node_modules");
if link.exists() {
return;
}
let dependencies = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../..")
.join("node_modules");
assert!(
dependencies.is_dir(),
"repository dependencies are installed at {}",
dependencies.display()
);
#[cfg(unix)]
std::os::unix::fs::symlink(&dependencies, &link).expect("link project dependencies");
#[cfg(windows)]
{
let status = std::process::Command::new("cmd")
.args(["/C", "mklink", "/J"])
.arg(&link)
.arg(&dependencies)
.status()
.expect("create project dependency junction");
assert!(status.success(), "create project dependency junction");
}
}