Skip to content

Commit 08b29a7

Browse files
committed
feat: install pre-push hook by build script
1 parent 06762dd commit 08b29a7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.githooks/pre-push.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cargo fmt --all
4+
leptosfmt .

build.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ use std::{
33
fs,
44
fs::{DirEntry, Metadata},
55
io::Write,
6-
path::PathBuf,
6+
path::{Path, PathBuf},
77
};
88

99
fn main() {
1010
println!("cargo:rerun-if-changed=extras");
1111

12+
// install pre-push hook
13+
if !Path::new(".git/hooks/pre-push").exists() {
14+
fs::hard_link(".githooks/pre-push.sh", ".git/hooks/pre-push").unwrap();
15+
}
16+
1217
let folders = fs::read_dir("extras").unwrap();
1318
if let Err(e) = fs::create_dir("src/extras") {
1419
if e.kind() != std::io::ErrorKind::AlreadyExists {

0 commit comments

Comments
 (0)