Added docs to build.rs.
This commit is contained in:
parent
2489bbb660
commit
5c2ebe8572
12
build.rs
12
build.rs
|
@ -1,15 +1,23 @@
|
|||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
/// If no `.env` file exists, this function will create an `.env` file and copy the contents
|
||||
/// of `sample.env` into it (this is why `sample.env` is kept under source control).
|
||||
///
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This function panics if both the `.env` file and `sample.env` file do not exist, or if we
|
||||
/// fail to copy `sample.env` into `.env`.
|
||||
fn create_env_file_if_dne() {
|
||||
let env_path = Path::new(".env");
|
||||
if !env_path.exists() {
|
||||
let sample_env_path = Path::new("sample.env");
|
||||
if !sample_env_path.exists() {
|
||||
panic!("neither the .env nor the sample.env files exist");
|
||||
panic!("neither the `.env` nor the `sample.env` files exist, one of these files must exist to build the `poagov`");
|
||||
}
|
||||
fs::copy(sample_env_path, env_path)
|
||||
.unwrap_or_else(|e| panic!("could not create .env file from sample.env: {:?}", e));
|
||||
.unwrap_or_else(|e| panic!("failed to create the `.env` file from `sample.env`: {:?}", e));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue