From 81df32af60147941c7d6005cf55ffd14c9665734 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Thu, 28 Dec 2023 18:57:30 +0100 Subject: Fix `alacritty migrate` with nonexistent imports Fixes #7473. --- alacritty/src/migrate.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'alacritty/src/migrate.rs') diff --git a/alacritty/src/migrate.rs b/alacritty/src/migrate.rs index 4d632af4..5f47b083 100644 --- a/alacritty/src/migrate.rs +++ b/alacritty/src/migrate.rs @@ -96,7 +96,7 @@ fn migrate_config( if options.dry_run && !options.silent { // Output new content to STDOUT. println!( - "\nv-----Start TOML for {path:?}-----v\n\n{toml}\n^-----End TOML for {path:?}-----^" + "\nv-----Start TOML for {path:?}-----v\n\n{toml}\n^-----End TOML for {path:?}-----^\n" ); } else if !options.dry_run { // Write the new toml configuration. @@ -124,7 +124,23 @@ fn migrate_imports( Ok(import) => import, Err(err) => return Err(format!("import error: {err}")), }; + + // Keep yaml import if path does not exist. + if !import.exists() { + if options.dry_run { + eprintln!("Keeping yaml config for nonexistent import: {import:?}"); + } + new_imports.push(Value::String(import.to_string_lossy().into())); + continue; + } + let new_path = migrate_config(options, &import, recursion_limit - 1)?; + + // Print new import path. + if options.dry_run { + println!("Successfully migrated import {import:?} to {new_path:?}"); + } + new_imports.push(Value::String(new_path)); } -- cgit