mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-24 12:14:05 +03:00
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:
parent
27fd8cc56c
commit
aaecb6a72e
5
.changes/tauri-build-dev-fn.md
Normal file
5
.changes/tauri-build-dev-fn.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-build": "patch:breaking"
|
||||
---
|
||||
|
||||
Renamed `dev` function to `is_dev`
|
5
.changes/tauri-dev-fn-const.md
Normal file
5
.changes/tauri-dev-fn-const.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": "patch:breaking"
|
||||
---
|
||||
|
||||
Renamed `dev` function to `is_dev` and marked it as `const fn`
|
@ -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
|
||||
|
@ -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 =
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user