diff --git a/.changes/fix-dmg-failed-with-out-dir.md b/.changes/fix-dmg-failed-with-out-dir.md new file mode 100644 index 00000000..fe468983 --- /dev/null +++ b/.changes/fix-dmg-failed-with-out-dir.md @@ -0,0 +1,5 @@ +--- +"cargo-packager": patch +--- + +Fixed dmg failed to bundle the application when out-dir does not exist. diff --git a/crates/packager/src/config/mod.rs b/crates/packager/src/config/mod.rs index aea68e04..64651319 100644 --- a/crates/packager/src/config/mod.rs +++ b/crates/packager/src/config/mod.rs @@ -1792,13 +1792,13 @@ impl Config { /// Returns the out dir. Defaults to the current directory. pub fn out_dir(&self) -> PathBuf { if self.out_dir.as_os_str().is_empty() { - std::env::current_dir().expect("failed to resolve cwd") - } else if self.out_dir.exists() { - dunce::canonicalize(&self.out_dir).unwrap_or_else(|_| self.out_dir.clone()) - } else { + return std::env::current_dir().expect("failed to resolve cwd"); + } + + if !self.out_dir.exists() { std::fs::create_dir_all(&self.out_dir).expect("failed to create output directory"); - self.out_dir.clone() } + dunce::canonicalize(&self.out_dir).unwrap_or_else(|_| self.out_dir.clone()) } /// Returns the binaries dir. Defaults to [`Self::out_dir`] if [`Self::binaries_dir`] is not set.