Fix WSL Hot Reload (#2721)
* feat: poll watcher * progress: wsl hot reload setting * feat: wsl poll setting
This commit is contained in:
1 parent
4e338accad
commit
b7127ad6ae
5 files changed
+159
-62
No files matched your search
@@ -25,6 +25,9 @@ pub struct CliSettings {
|
||||
pub always_open_browser: Option<bool>,
|
||||
/// Describes whether desktop apps in development will be pinned always-on-top.
|
||||
pub always_on_top: Option<bool>,
|
||||
/// Describes the interval in seconds that the CLI should poll for file changes on WSL.
|
||||
#[serde(default = "default_wsl_file_poll_interval")]
|
||||
pub wsl_file_poll_interval: Option<u16>,
|
||||
}
|
||||
|
||||
impl CliSettings {
|
||||
@@ -74,7 +77,19 @@ impl CliSettings {
|
||||
CrateConfigError::Io(Error::new(ErrorKind::Other, e.to_string()))
|
||||
})?;
|
||||
|
||||
let result = fs::write(path.clone(), data.clone());
|
||||
// Create the directory structure if it doesn't exist.
|
||||
let parent_path = path.parent().unwrap();
|
||||
if let Err(e) = fs::create_dir_all(parent_path) {
|
||||
error!(
|
||||
?data,
|
||||
?path,
|
||||
"failed to create directories for settings file"
|
||||
);
|
||||
return Err(CrateConfigError::Io(e));
|
||||
}
|
||||
|
||||
// Write the data.
|
||||
let result = fs::write(&path, data.clone());
|
||||
if let Err(e) = result {
|
||||
error!(?data, ?path, "failed to save global cli settings");
|
||||
return Err(CrateConfigError::Io(e));
|
||||
@@ -102,3 +117,7 @@ impl CliSettings {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn default_wsl_file_poll_interval() -> Option<u16> {
|
||||
Some(2)
|
||||
}
|
||||
Reference in new issue
Block a user