Don't use $HOME env variable because it doesn't always work
This commit is contained in:
parent
ec10c2f6bd
commit
741af8c6f1
|
@ -46,6 +46,7 @@ name = "forgebuild"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glob",
|
"glob",
|
||||||
|
"home",
|
||||||
"hostname",
|
"hostname",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -77,6 +78,15 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "home"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hostname"
|
name = "hostname"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
|
|
@ -16,3 +16,5 @@ serde_json = "1.0"
|
||||||
structopt = "0.3"
|
structopt = "0.3"
|
||||||
# Debug Context for translations
|
# Debug Context for translations
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
# Detect home folder
|
||||||
|
home = "0.5.3"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
use home::home_dir;
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
#[structopt(
|
#[structopt(
|
||||||
|
@ -26,7 +27,7 @@ impl Cli {
|
||||||
// Returns an error when the path doesn't exist
|
// Returns an error when the path doesn't exist
|
||||||
PathBuf::from(basedir)
|
PathBuf::from(basedir)
|
||||||
} else {
|
} else {
|
||||||
let mut home_path = PathBuf::from(env::var("HOME").expect("No $HOME in env"));
|
let mut home_path = home_dir().expect("No HOME folder found.");
|
||||||
home_path.push(".forgebuild");
|
home_path.push(".forgebuild");
|
||||||
home_path
|
home_path
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue