refactor: rename tauri::dev to is_dev and mark as constant fn (#9890)

* refactor: made `tauri::dev` as constant function

this enables the `tauri::dev()` can be used as const or static

* is_dev && change files

---------

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
This commit is contained in:
Rajaniraiyn R 2024-05-27 21:33:48 +05:30 committed by GitHub
parent 27fd8cc56c
commit aaecb6a72e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-build": "patch:breaking"
---
Renamed `dev` function to `is_dev`

View File

@ -0,0 +1,5 @@
---
"tauri": "patch:breaking"
---
Renamed `dev` function to `is_dev` and marked it as `const fn`

View File

@ -121,7 +121,7 @@ impl CodegenContext {
);
let code = context_codegen(ContextData {
dev: crate::dev(),
dev: crate::is_dev(),
config,
config_parent,
// it's very hard to have a build script for unit tests, so assume this is always called from

View File

@ -386,7 +386,7 @@ impl Attributes {
}
}
pub fn dev() -> bool {
pub fn is_dev() -> bool {
std::env::var("DEP_TAURI_DEV")
.expect("missing `cargo:dev` instruction, please update tauri to latest")
== "true"
@ -474,7 +474,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
mobile::generate_gradle_files(project_dir, &config)?;
}
cfg_alias("dev", dev());
cfg_alias("dev", is_dev());
let ws_path = get_workspace_dir()?;
let mut manifest =

View File

@ -335,7 +335,7 @@ macro_rules! tauri_build_context {
pub use pattern::Pattern;
/// Whether we are running in development mode or not.
pub fn dev() -> bool {
pub const fn is_dev() -> bool {
!cfg!(feature = "custom-protocol")
}

View File

@ -330,7 +330,7 @@ impl<R: Runtime> AppManager<R> {
}
fn csp(&self) -> Option<Csp> {
if !crate::dev() {
if !crate::is_dev() {
self.config.app.security.csp.clone()
} else {
self