From 3d6417fc7a117c36195f45d1d5e30a43fc5365ab Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Wed, 8 Nov 2023 13:01:58 +0300 Subject: [PATCH] check config file before prompts on x setup Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/setup.rs | 24 ++++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 04a1644377039..f29f9873d2a7f 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -122,6 +122,17 @@ impl Step for Profile { return; } + let path = &run.builder.config.config.clone().unwrap_or(PathBuf::from("config.toml")); + if path.exists() { + eprintln!(); + eprintln!( + "error: you asked for a new config file, but one already exists at `{}`", + t!(path.canonicalize()).display() + ); + + crate::exit!(1); + } + // for Profile, `run.paths` will have 1 and only 1 element // this is because we only accept at most 1 path from user input. // If user calls `x.py setup` without arguments, the interactive TUI @@ -204,19 +215,6 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) { if profile == Profile::None { return; } - if path.exists() { - eprintln!(); - eprintln!( - "error: you asked `x.py` to setup a new config file, but one already exists at `{}`", - path.display() - ); - eprintln!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display()); - eprintln!( - "note: this will use the configuration in {}", - profile.include_path(&config.src).display() - ); - crate::exit!(1); - } let latest_change_id = CONFIG_CHANGE_HISTORY.last().unwrap(); let settings = format!(