Skip to content

Commit

Permalink
fix(cli.rs): prefix the "before script" env vars with TAURI_ (#3274)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg authored Jan 24, 2022
1 parent d801cc8 commit 9bb6897
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .changes/before-script-envs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"cli.rs": patch
---

Define `PLATFORM`, `ARCH`, `FAMILY`, `PLATFORM_TYPE` and `TAURI_DEBUG` environment variables for the `beforeDevCommand` and `beforeBuildCommand` scripts.
Define `TAURI_PLATFORM`, `TAURI_ARCH`, `TAURI_FAMILY`, `TAURI_PLATFORM_TYPE`, `TAURI_PLATFORM_VERSION` and `TAURI_DEBUG` environment variables for the `beforeDevCommand` and `beforeBuildCommand` scripts.
4 changes: 2 additions & 2 deletions tooling/cli.rs/config_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,11 +850,11 @@ pub struct BuildConfig {
pub dist_dir: AppUrl,
/// A shell command to run before `tauri dev` kicks in.
///
/// The PLATFORM, ARCH, FAMILY, PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
/// The TAURI_PLATFORM, TAURI_ARCH, TAURI_FAMILY, TAURI_PLATFORM_VERSION, TAURI_PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
pub before_dev_command: Option<String>,
/// A shell command to run before `tauri build` kicks in.
///
/// The PLATFORM, ARCH, FAMILY, PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
/// The TAURI_PLATFORM, TAURI_ARCH, TAURI_FAMILY, TAURI_PLATFORM_VERSION, TAURI_PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
pub before_build_command: Option<String>,
/// Features passed to `cargo` commands.
pub features: Option<Vec<String>>,
Expand Down
14 changes: 7 additions & 7 deletions tooling/cli.rs/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ pub fn execute_with_output(cmd: &mut Command) -> crate::Result<()> {
pub fn command_env(debug: bool) -> HashMap<String, String> {
let mut map = HashMap::new();

map.insert("PLATFORM".into(), std::env::consts::OS.into());
map.insert("ARCH".into(), std::env::consts::ARCH.into());
map.insert("FAMILY".into(), std::env::consts::FAMILY.into());
map.insert("VERSION".into(), os_info::get().version().to_string());
map.insert("TAURI_PLATFORM".into(), std::env::consts::OS.into());
map.insert("TAURI_ARCH".into(), std::env::consts::ARCH.into());
map.insert("TAURI_FAMILY".into(), std::env::consts::FAMILY.into());
map.insert("TAURI_PLATFORM_VERSION".into(), os_info::get().version().to_string());

#[cfg(target_os = "linux")]
map.insert("PLATFORM_TYPE".into(), "Linux".into());
map.insert("TAURI_PLATFORM_TYPE".into(), "Linux".into());
#[cfg(target_os = "windows")]
map.insert("PLATFORM_TYPE".into(), "Windows_NT".into());
map.insert("TAURI_PLATFORM_TYPE".into(), "Windows_NT".into());
#[cfg(target_os = "macos")]
map.insert("PLATFORM_TYPE".into(), "Darwin".into());
map.insert("TAURI_PLATFORM_TYPE".into(), "Darwin".into());

if debug {
map.insert("TAURI_DEBUG".into(), "true".to_string());
Expand Down

0 comments on commit 9bb6897

Please sign in to comment.