1use std::path::PathBuf;
2
3use crud_path::{add_github_path, is_github};
4
5pub const IS_WINDOWS: bool = cfg!(target_os = "windows");
6
7pub fn add_to_path(dir: &str) {
8 if crud_path::has_path(dir) {
9 return;
10 }
11
12 if is_github() {
13 add_github_path(dir);
14 println!("Successfully added {dir} to github's $PATH");
15 }
16
17 if let Some(sh) = crud_path::add_path(dir) {
18 println!("Successfully added {dir} to {sh}'s $PATH");
19 } else {
20 println!("You need to add {dir} to your $PATH");
21 }
22}
23
24pub fn get_install_dir() -> PathBuf {
25 let mut home = dirs::home_dir().expect("Failed to get home_dir");
26 home.push(".easy-install");
27
28 if !home.exists() {
29 std::fs::create_dir_all(&home).expect("Failed to create_dir home_dir");
30 }
31 home
34}