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 }
15
16 if let Some(sh) = crud_path::add_path(dir) {
17 println!("Successfully added {dir} to {sh}'s $PATH");
18 } else {
19 println!("You need to add {dir} to your $PATH");
20 }
21}
22
23pub fn get_install_dir() -> PathBuf {
41 let mut home = dirs::home_dir().expect("Failed to get home_dir");
42 home.push(".easy-install");
43
44 if !home.exists() {
45 std::fs::create_dir_all(&home).expect("Failed to create_dir home_dir");
46 }
47 let home_str = home.to_str().expect("Failed to get home_dir string");
48 add_to_path(home_str);
49 home
50}