Repository: tauri-apps/tauri
File: tooling/cli/src/build.rs (Rust)

Code before:
          "beforeBundleCommand",
          before_bundle,
          &interface,
          options.debug,
        )?;
      }
    }

    let mut settings = app_settings
      .get_bundler_settings(&options.into(), config_, out_dir, package_types)
      .with_context(|| "failed to build bundler settings")?;

    settings.set_log_level(match verbosity {
      0 => log::Level::Error,
      1 => log::Level::Info,
      _ => log::Level::Trace,
    });

    // set env vars used by the bundler
    #[cfg(target_os = "linux")]
    {
      if config_.tauri.bundle.appimage.bundle_media_framework {
        std::env::set_var("APPIMAGE_BUNDLE_GSTREAMER", "1");
      }

      // TODO: Consider using the plugin crate directly
      if let Some(open) = config_.plugins.0.get("shell").and_then(|v| v.get("open")) {
        if open.as_bool().is_some_and(|x| x) || open.is_string() {
          std::env::set_var("APPIMAGE_BUNDLE_XDG_OPEN", "1");
        }
      }

      if settings.deep_link_protocols().is_some() {
        std::env::set_var("APPIMAGE_BUNDLE_XDG_MIME", "1");
      }
    }

    let bundles = bundle_project(settings)
      .map_err(|e| anyhow::anyhow!("{:#}", e))
      .with_context(|| "failed to bundle project")?;

    let updater_bundles: Vec<&Bundle> = bundles
      .iter()
      .filter(|bundle| bundle.package_type == PackageType::Updater)
      .collect();
    // If updater is active and we bundled it
    if config_.tauri.bundle.updater.active && !updater_bundles.is_empty() {
      // if no password provided we use an empty string
      let password = var_os("TAURI_SIGNING_PRIVATE_KEY_PASSWORD")
        .map(|v| v.to_str().unwrap().to_string())
        .or_else(|| if ci { Some("".into()) } else { None });

Review comment (suggestion):
not sure what this means but the way it is implemented right now is okay (until a better approach to extend the bunder)

Code after:
          "beforeBundleCommand",
          before_bundle,
          &interface,
          options.debug,
        )?;
      }
    }

    let mut settings = app_settings
      .get_bundler_settings(&options.into(), config_, out_dir, package_types)
      .with_context(|| "failed to build bundler settings")?;

    settings.set_log_level(match verbosity {
      0 => log::Level::Error,
      1 => log::Level::Info,
      _ => log::Level::Trace,
    });

    // set env vars used by the bundler
    #[cfg(target_os = "linux")]
    {
      if config_.tauri.bundle.appimage.bundle_media_framework {
        std::env::set_var("APPIMAGE_BUNDLE_GSTREAMER", "1");
      }

      if let Some(open) = config_.plugins.0.get("shell").and_then(|v| v.get("open")) {
        if open.as_bool().is_some_and(|x| x) || open.is_string() {
          std::env::set_var("APPIMAGE_BUNDLE_XDG_OPEN", "1");
        }
      }

      if settings.deep_link_protocols().is_some() {
        std::env::set_var("APPIMAGE_BUNDLE_XDG_MIME", "1");
      }
    }

    let bundles = bundle_project(settings)
      .map_err(|e| anyhow::anyhow!("{:#}", e))
      .with_context(|| "failed to bundle project")?;

    let updater_bundles: Vec<&Bundle> = bundles
      .iter()
      .filter(|bundle| bundle.package_type == PackageType::Updater)
      .collect();
    // If updater is active and we bundled it
    if config_.tauri.bundle.updater.active && !updater_bundles.is_empty() {
      // if no password provided we use an empty string
      let password = var_os("TAURI_SIGNING_PRIVATE_KEY_PASSWORD")
        .map(|v| v.to_str().unwrap().to_string())
        .or_else(|| if ci { Some("".into()) } else { None });
      // get the private key