From 01eff2954bc4ef81712662195c549234d4fe9d4b Mon Sep 17 00:00:00 2001 From: Andriy Massimilla Date: Mon, 7 Oct 2024 11:30:19 -0400 Subject: [PATCH] Don't require canonicalize when getting project name, version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/core/hook.rs | 2 +- src/lib.rs | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9e9d1f..0e91be8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1928,7 +1928,7 @@ dependencies = [ [[package]] name = "spackle" -version = "0.2.0" +version = "0.2.1" dependencies = [ "async-process", "async-stream", diff --git a/Cargo.toml b/Cargo.toml index 758bcde..b8b4368 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spackle" -version = "0.2.0" +version = "0.2.1" edition = "2021" repository = "https://github.com/a2-ai/spackle" description = "A frictionless project templating tool." diff --git a/src/core/hook.rs b/src/core/hook.rs index b24bf61..945044b 100644 --- a/src/core/hook.rs +++ b/src/core/hook.rs @@ -659,7 +659,7 @@ mod tests { ".", &HashMap::from([ ("field_1".to_string(), "echo".to_string()), - ("field_2".to_string(), "out1".to_string()), + ("field_2".to_string(), "project".to_string()), ]), &HashMap::new(), None, diff --git a/src/lib.rs b/src/lib.rs index b138645..9712539 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,11 +50,12 @@ impl std::error::Error for GenerateError { pub fn get_project_name(out_dir: &Path) -> String { let path = match out_dir.canonicalize() { Ok(path) => path, - Err(_) => "project".into(), + // If the path cannot be canonicalized (e.g. not created yet), we can ignore + Err(_) => out_dir.to_path_buf(), }; path.file_stem() - .unwrap_or_default() + .unwrap_or("project".as_ref()) .to_string_lossy() .to_string() }