Skip to content

Commit

Permalink
feat(cli): add prompt information when file changing detected, closes #…
Browse files Browse the repository at this point in the history
…5417 (#5428)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
Tnze and lucasfernog authored Oct 19, 2022
1 parent ef41c5b commit 9076d5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/cli-watcher-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---

Log dev watcher file change detection.
11 changes: 10 additions & 1 deletion tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use tauri_bundler::{

use super::{AppSettings, ExitReason, Interface};
use crate::helpers::{
app_paths::tauri_dir,
app_paths::{app_dir, tauri_dir},
config::{reload as reload_config, wix_settings, Config},
};

Expand Down Expand Up @@ -342,6 +342,7 @@ impl Rust {
) -> crate::Result<()> {
let process = Arc::new(Mutex::new(child));
let (tx, rx) = sync_channel(1);
let app_path = app_dir();
let tauri_path = tauri_dir();
let workspace_path = get_workspace_dir()?;

Expand Down Expand Up @@ -393,10 +394,18 @@ impl Rust {
let event_path = event.path;

if event_path.file_name() == Some(OsStr::new("tauri.conf.json")) {
info!("Tauri configuration changed. Rewriting manifest...");
let config = reload_config(options.config.as_deref())?;
self.app_settings.manifest =
rewrite_manifest(config.lock().unwrap().as_ref().unwrap())?;
} else {
info!(
"File {} changed. Rebuilding application...",
event_path
.strip_prefix(&app_path)
.unwrap_or(&event_path)
.display()
);
// When tauri.conf.json is changed, rewrite_manifest will be called
// which will trigger the watcher again
// So the app should only be started when a file other than tauri.conf.json is changed
Expand Down

0 comments on commit 9076d5d

Please sign in to comment.