Skip to content

Commit b26c9b5

Browse files
committed
check config file before prompts on x setup
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent 7cc997d commit b26c9b5

File tree

1 file changed

+11
-13
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+11
-13
lines changed

src/bootstrap/src/core/build_steps/setup.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ impl Step for Profile {
122122
return;
123123
}
124124

125+
let path = &run.builder.config.config.clone().unwrap_or(PathBuf::from("config.toml"));
126+
if path.exists() {
127+
eprintln!();
128+
eprintln!(
129+
"error: you asked for a new config file, but one already exists at `{}`",
130+
t!(path.canonicalize()).display()
131+
);
132+
133+
crate::exit!(1);
134+
}
135+
125136
// for Profile, `run.paths` will have 1 and only 1 element
126137
// this is because we only accept at most 1 path from user input.
127138
// If user calls `x.py setup` without arguments, the interactive TUI
@@ -195,19 +206,6 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) {
195206
if profile == Profile::None {
196207
return;
197208
}
198-
if path.exists() {
199-
eprintln!();
200-
eprintln!(
201-
"error: you asked `x.py` to setup a new config file, but one already exists at `{}`",
202-
path.display()
203-
);
204-
eprintln!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display());
205-
eprintln!(
206-
"note: this will use the configuration in {}",
207-
profile.include_path(&config.src).display()
208-
);
209-
crate::exit!(1);
210-
}
211209

212210
let latest_change_id = CONFIG_CHANGE_HISTORY.last().unwrap();
213211
let settings = format!(

0 commit comments

Comments
 (0)