Skip to content

Commit

Permalink
Getting config directory by absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
dqkqd authored and github-actions[bot] committed Oct 13, 2024
1 parent 498c2a5 commit 662579d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions selene/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,16 @@ fn start(mut options: opts::Options) {
};

match toml::from_str(&config_contents) {
Ok(config) => (
config,
Path::new(&config_file).parent().map(Path::to_path_buf),
),
Ok(config) => {
// Get config directory to using absolute path.
// There is case where `config = Some("selene.toml")`,
// which returns `""`` when getting parent directory.
let config_directory = Path::new(&config_file)
.canonicalize()
.ok()
.and_then(|path| path.parent().map(|path| path.to_path_buf()));
(config, config_directory)
}
Err(error) => {
error!("Config file not in correct format: {}", error);
std::process::exit(1);
Expand Down

0 comments on commit 662579d

Please sign in to comment.