-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
41 lines (33 loc) · 966 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::process::Command;
use std::env;
use std::process::ExitStatus;
fn main() {
dotenv::dotenv().ok();
let mode = match env::var("MODE") {
Ok(val) => val,
Err(_) => {
eprintln!("MODE is not set");
return;
}
};
// Print a message to stderr
Command::new("echo")
.arg("get_db_url.rs: script started")
.status()
.expect("failed to run echo");
let status: ExitStatus;
if mode == "dev" {
status = Command::new("bash")
.arg("./get_db_url.sh")
.status()
.expect("Failed to execute Bash script");
// Check if the script executed successfully
if !status.success() {
panic!("Failed to run get_database_url.sh");
}
if status.success() {
eprintln!("retrieved db url");
}
}
println!("cargo:rerun-if-changed=build.rs"); // This should be build.rs
}