Skip to content

Commit 68302bb

Browse files
committed
refactor(new): Group related calls
1 parent 61debf8 commit 68302bb

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/cargo/ops/cargo_new.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,14 @@ fn calculate_new_project_kind(
439439

440440
pub fn new(opts: &NewOptions, config: &Config) -> CargoResult<()> {
441441
let path = &opts.path;
442+
442443
if path.exists() {
443444
anyhow::bail!(
444445
"destination `{}` already exists\n\n\
445446
Use `cargo init` to initialize the directory",
446447
path.display()
447448
)
448449
}
449-
450450
check_path(path, &mut config.shell())?;
451451

452452
let is_bin = opts.kind.is_bin();
@@ -484,13 +484,11 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<NewProjectKind> {
484484
if path.join("Cargo.toml").exists() {
485485
anyhow::bail!("`cargo init` cannot be run on existing Cargo packages")
486486
}
487-
488487
check_path(path, &mut config.shell())?;
489488

490489
let name = get_name(path, opts)?;
491490

492491
let mut src_paths_types = vec![];
493-
494492
detect_source_paths_and_types(path, name, &mut src_paths_types)?;
495493

496494
let kind = calculate_new_project_kind(opts.kind, opts.auto_detect_kind, &src_paths_types);

0 commit comments

Comments
 (0)