Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit295be83

Browse files
authored
Fix some autoreloading bugs (#972)
1 parented6654e commit295be83

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
lines changed

‎pgml-apps/cargo-pgml-components/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎pgml-apps/cargo-pgml-components/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name ="cargo-pgml-components"
3-
version ="0.1.9"
3+
version ="0.1.10"
44
edition ="2021"
55
authors = ["PostgresML <team@postgresml.org>"]
66
license ="MIT"

‎pgml-apps/cargo-pgml-components/src/frontend/components.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use convert_case::{Case,Casing};
22
use sailfish::TemplateOnce;
3-
use std::fs::{create_dir_all, read_dir};
3+
use std::fs::{create_dir_all, read_dir, read_to_string};
44
use std::path::Path;
55
use std::process::exit;
66

77
usecrate::frontend::templates;
8-
usecrate::util::{error, info, unwrap_or_exit, write_to_file};
8+
usecrate::util::{compare_strings,error, info, unwrap_or_exit, write_to_file};
99

1010
staticCOMPONENT_DIRECTORY:&'staticstr ="src/components";
1111
staticCOMPONENT_MOD:&'staticstr ="src/components/mod.rs";
@@ -131,7 +131,13 @@ pub fn update_modules() {
131131
}
132132

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

135-
unwrap_or_exit!(write_to_file(&Path::new(COMPONENT_MOD),&modules));
136-
info(&format!("written {}",COMPONENT_MOD));
136+
if !unwrap_or_exit!(compare_strings(&modules,&existing_modules)){
137+
debug!("mod.rs is different");
138+
unwrap_or_exit!(write_to_file(&Path::new(COMPONENT_MOD),&modules));
139+
info(&format!("written {}",COMPONENT_MOD));
140+
}
141+
142+
debug!("mod.rs is the same");
137143
}

‎pgml-apps/cargo-pgml-components/src/util.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use owo_colors::OwoColorize;
2-
use std::fs::File;
2+
use std::fs::{read_to_string,File};
33
use std::io::{ErrorKind,Write};
44
use std::path::Path;
55
use std::process::Command;
@@ -78,3 +78,16 @@ pub fn write_to_file(path: &Path, content: &str) -> std::io::Result<()> {
7878

7979
Ok(())
8080
}
81+
82+
#[allow(dead_code)]
83+
pubfncompare_files(path1:&Path,path2:&Path) -> std::io::Result<bool>{
84+
let content1 =read_to_string(path1)?;
85+
let content2 =read_to_string(path2)?;
86+
87+
compare_strings(&content1,&content2)
88+
}
89+
90+
pubfncompare_strings(string1:&str,string2:&str) -> std::io::Result<bool>{
91+
// TODO: faster string comparison method needed.
92+
Ok(string1 == string2)
93+
}

‎pgml-dashboard/static/js/.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
main.js
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
<% use crate::components::*; %>
2+
13
<h3class="h3">Playground</h3>
4+
5+
<divclass="mb-3">
6+
<%+ GithubIcon::new() %>
7+
</div>
8+
9+
<divclass="mb-3">
10+
<%- Navbar::render(None) %>
11+
</div>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp