Skip to content

Fix some autoreloading bugs #972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Start fixing autoreload bug
  • Loading branch information
levkk committed Aug 31, 2023
commit 2e6896d9752779c349dd864e4e27de0529b9a0c6
2 changes: 1 addition & 1 deletion pgml-apps/cargo-pgml-components/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions pgml-apps/cargo-pgml-components/src/frontend/components.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use convert_case::{Case, Casing};
use sailfish::TemplateOnce;
use std::fs::{create_dir_all, read_dir};
use std::fs::{create_dir_all, read_dir, read_to_string};
use std::path::Path;
use std::process::exit;

Expand Down Expand Up @@ -131,7 +131,13 @@ pub fn update_modules() {
}

let modules = unwrap_or_exit!(templates::Mod { modules }.render_once());
let existing_modules = unwrap_or_exit!(read_to_string(COMPONENT_MOD));

unwrap_or_exit!(write_to_file(&Path::new(COMPONENT_MOD), &modules));
info(&format!("written {}", COMPONENT_MOD));
if modules != existing_modules {
debug!("mod.rs is different");
unwrap_or_exit!(write_to_file(&Path::new(COMPONENT_MOD), &modules));
info(&format!("written {}", COMPONENT_MOD));
}

debug!("mod.rs is the same");
}
11 changes: 9 additions & 2 deletions pgml-apps/cargo-pgml-components/src/frontend/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::util::{info, unwrap_or_exit, warn};
/// The name of the JS file that imports all other JS files
/// created in the modules.
static MODULES_FILE: &'static str = "static/js/modules.js";
static MODULES_FILE_TMP: &'static str = "/tmp/pgml-components-modules.js";

/// The JS bundle.
static JS_FILE: &'static str = "static/js/bundle.js";
Expand Down Expand Up @@ -52,7 +53,7 @@ fn assemble_modules() {
!path.contains("main.js") && !path.contains("bundle.js") && !path.contains("modules.js")
});

let mut modules = unwrap_or_exit!(File::create(MODULES_FILE));
let mut modules = unwrap_or_exit!(File::create(MODULES_FILE_TMP));

unwrap_or_exit!(writeln!(&mut modules, "// Build with --bin components"));
unwrap_or_exit!(writeln!(
Expand Down Expand Up @@ -92,7 +93,13 @@ fn assemble_modules() {
));
}

info(&format!("written {}", MODULES_FILE));
let new_modules = unwrap_or_exit!(read_to_string(MODULES_FILE_TMP));
let old_modules = unwrap_or_exit!(read_to_string(MODULES_FILE));

if new_modules != old_modules {
unwrap_or_exit!(copy(MODULES_FILE_TMP, MODULES_FILE));
info(&format!("written {}", MODULES_FILE));
}
}

pub fn bundle() {
Expand Down
1 change: 0 additions & 1 deletion pgml-dashboard/src/components/.ignore

This file was deleted.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy