-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
30 lines (27 loc) · 847 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::path::Path;
use std::{fs, io};
// Copies git hooks within the hooks folder to .git/hooks.
fn main() {
let result = copy_dir_all("hooks", ".git/hooks");
match result {
Ok(_) => (),
Err(e) => println!(
"cargo:warning=An error occurred while trying to copy git hooks: {}",
e
),
};
}
// Borrowed from https://stackoverflow.com/a/65192210
fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
fs::create_dir_all(&dst)?;
for entry in fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}