-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): allow a plugin build script to read the plugin config obj…
…ect (#7447)
- Loading branch information
1 parent
aba04fa
commit 522de0e
Showing
5 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"tauri-cli": patch:feat | ||
"@tauri-apps/cli": patch:feat | ||
--- | ||
|
||
Expose an environment variable `TAURI_${PLUGIN_NAME}_PLUGIN_CONFIG` for each defined plugin configuration object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"tauri-build": patch:feat | ||
--- | ||
|
||
Added the `config::plugin_config` function to read the plugin configuration set from the CLI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use serde::de::DeserializeOwned; | ||
|
||
use std::{env::var, io::Cursor}; | ||
|
||
pub fn plugin_config<T: DeserializeOwned>(name: &str) -> Option<T> { | ||
if let Ok(config_str) = var(format!( | ||
"TAURI_{}_PLUGIN_CONFIG", | ||
name.to_uppercase().replace('-', "_") | ||
)) { | ||
serde_json::from_reader(Cursor::new(config_str)) | ||
.map(Some) | ||
.expect("failed to parse configuration") | ||
} else { | ||
None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters