Skip to content

Commit

Permalink
fix(cli): always read custom config file from CWD, closes #4067 (#4074)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored May 7, 2022
1 parent 35f2147 commit a1929c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/dev-cmd-config-arg.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tooling/cli/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1929c6

Please sign in to comment.