Skip to content

Commit

Permalink
chore: adjust load_env() to add .flaskenv and NODE_ENV support
Browse files Browse the repository at this point in the history
  • Loading branch information
linux-china committed Apr 1, 2024
1 parent af10e7c commit c5767db
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn main() {
if matches.contains_id("tasks") {
// load .env for tasks
if !no_dotenv {
dotenv().ok();
load_env();
}
// inject polyglot for tasks
polyglot::inject_languages();
Expand Down Expand Up @@ -480,6 +480,16 @@ fn format_description(description: &str) -> String {
return short_desc;
}

fn load_env() {
dotenv().ok();
if env::current_dir().unwrap().join(".flaskenv").exists() {
dotenv::from_filename(".flaskenv").ok();
}
if let Some(node_env) = env::var("NODE_ENV") {
dotenv::from_filename(format!(".env.{}", node_env)).ok();
}
}

#[cfg(target_family = "unix")]
fn set_executable(path: &str) {
use std::os::unix::fs::PermissionsExt;
Expand Down

0 comments on commit c5767db

Please sign in to comment.