Parcourir la source

fix(cli.rs): prefix the "before script" env vars with `TAURI_` (#3274)

Jonas Kruckenberg il y a 3 ans
Parent
commit
9bb68973dd

+ 1 - 1
.changes/before-script-envs.md

@@ -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.

+ 2 - 2
tooling/cli.rs/config_definition.rs

@@ -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>>,

+ 7 - 7
tooling/cli.rs/src/helpers/mod.rs

@@ -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());