Skip to content

Commit

Permalink
fix(cli): map --profile dev to debug folder when finding executab…
Browse files Browse the repository at this point in the history
…le (#8776)
  • Loading branch information
amrbashir authored Feb 5, 2024
1 parent cc3d8e7 commit b0f2781
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 69 deletions.
6 changes: 6 additions & 0 deletions .changes/cli-dev-profile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'tauri-cli': 'patch:bug'
'@tauri-apps/cli': 'patch:bug'
---

Fix `fail to rename app` when using `--profile dev`.
4 changes: 2 additions & 2 deletions tooling/bundler/src/bundle/updater_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use std::{
path::{Path, PathBuf},
};

use flate2::{write::GzEncoder, Compression};

use anyhow::Context;
use log::info;
use zip::write::FileOptions;
Expand Down Expand Up @@ -236,6 +234,8 @@ pub fn create_zip(src_file: &Path, dst_file: &Path) -> crate::Result<PathBuf> {

#[cfg(not(target_os = "windows"))]
fn create_tar(src_dir: &Path, dest_path: &Path) -> crate::Result<PathBuf> {
use flate2::{write::GzEncoder, Compression};

let dest_file = common::create_file(dest_path)?;
let gzip_encoder = GzEncoder::new(dest_file, Compression::default());

Expand Down
74 changes: 13 additions & 61 deletions tooling/cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ impl AppSettings for RustAppSettings {
.expect("Cargo manifest must have the `package.name` field");

let out_dir = self
.out_dir(options.target.clone(), get_profile(options))
.out_dir(options.target.clone(), get_profile_dir(options).to_string())
.with_context(|| "failed to get project out directory")?;

let binary_extension: String = if self.target_triple.contains("windows") {
Expand Down Expand Up @@ -986,13 +986,20 @@ pub fn get_workspace_dir() -> crate::Result<PathBuf> {
)
}

pub fn get_profile(options: &Options) -> String {
pub fn get_profile(options: &Options) -> &str {
options
.args
.iter()
.position(|a| a == "--profile")
.map(|i| options.args[i + 1].clone())
.unwrap_or_else(|| if options.debug { "debug" } else { "release" }.into())
.map(|i| options.args[i + 1].as_str())
.unwrap_or_else(|| if options.debug { "debug" } else { "release" })
}

pub fn get_profile_dir(options: &Options) -> &str {
match get_profile(options) {
"dev" => "debug",
profile => profile,
}
}

#[allow(unused_variables)]
Expand Down
4 changes: 2 additions & 2 deletions tooling/cli/src/interface/rust/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use super::{get_profile, AppSettings, DevChild, ExitReason, Options, RustAppSettings, Target};
use super::{get_profile_dir, AppSettings, DevChild, ExitReason, Options, RustAppSettings, Target};
use crate::CommandExt;
use tauri_utils::display_path;

Expand Down Expand Up @@ -125,7 +125,7 @@ pub fn build(
options.target.replace(triple.into());

let triple_out_dir = app_settings
.out_dir(Some(triple.into()), get_profile(&options))
.out_dir(Some(triple.into()), get_profile_dir(&options).to_string())
.with_context(|| format!("failed to get {triple} out dir"))?;

build_production_app(options, available_targets, config_features.clone())
Expand Down

0 comments on commit b0f2781

Please sign in to comment.