Skip to content

Commit

Permalink
Surely this fixes it?
Browse files Browse the repository at this point in the history
  • Loading branch information
ReCore-sys committed Jun 26, 2024
1 parent fcabc58 commit a2b5b3e
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#![feature(box_into_inner)]
#![feature(fs_try_exists)]

use std::fs;
use std::{env, fs};
use std::sync::Arc;
#[allow(unused_imports)]
use tokio::fs::try_exists;
#[warn(unused_imports)]
use clap::{Parser};

use log::{debug, info, trace};
use log::{debug, error, info, trace};
use tokio::net::TcpListener;
use tokio::sync::RwLock;

Expand All @@ -35,10 +35,27 @@ async fn main() -> Result<()> {

let args = Cli::parse();

// run setup if the flag is set or the config file does not exist in release mode
if args.setup || (!fs::try_exists("config.toml")? && !cfg!(debug_assertions)) {
if env::var("GITHUB_ACTIONS").is_ok() {
env::set_var("RUST_LOG", "info");
}
else if args.setup {
setup::setup().await?;
return Ok(())
return Ok(());
} else {
let exe = std::env::current_exe()?;
let dir = exe.parent();
match dir {
Some(dir) => {
let config_path = dir.join("config.toml");
if !config_path.exists() {
setup::setup().await?;
}
}
None => {
error!("No parent directory found for executable! Please don't try run ferrumc from root, its really not a good idea");
return Ok(());
}
}
}

utils::setup_logger();
Expand Down

0 comments on commit a2b5b3e

Please sign in to comment.