fix(cli): always read custom config file from CWD, closes #4067 (#4074)

This commit is contained in:
Lucas Fernandes Nogueira
2022-05-07 12:20:58 -07:00
committed by GitHub
parent 35f2147161
commit a1929c6dac
3 changed files with 11 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---
**Breaking change:** The `dev` command now reads the custom config file from CWD instead of the Tauri folder.

View File

@@ -50,7 +50,7 @@ pub fn command(options: Options) -> Result<()> {
Some(if config.starts_with('{') {
config.to_string()
} else {
std::fs::read_to_string(&config)?
std::fs::read_to_string(&config).with_context(|| "failed to read custom configuration")?
})
} else {
None

View File

@@ -79,16 +79,18 @@ pub fn command(options: Options) -> Result<()> {
fn command_internal(options: Options) -> Result<()> {
let tauri_path = tauri_dir();
set_current_dir(&tauri_path).with_context(|| "failed to change current working directory")?;
let merge_config = if let Some(config) = &options.config {
Some(if config.starts_with('{') {
config.to_string()
} else {
std::fs::read_to_string(&config)?
std::fs::read_to_string(&config).with_context(|| "failed to read custom configuration")?
})
} else {
None
};
set_current_dir(&tauri_path).with_context(|| "failed to change current working directory")?;
let config = get_config(merge_config.as_deref())?;
if let Some(before_dev) = &config