1
Fork 0
bauke-xyz/source/copy.rs

43 lines
952 B
Rust
Raw Normal View History

//! The logic for files that need be directly copied over.
2021-12-13 23:50:38 +00:00
use std::{fs, path::Path, process::Command};
use color_eyre::Result;
/// Struct to contain functionality for copying.
2021-12-13 23:50:38 +00:00
pub struct Copy;
impl Copy {
/// Copy all the files to their respective destinations.
2021-12-13 23:50:38 +00:00
pub fn write(
build_dir: &Path,
public_dir: &Path,
source_dir: &Path,
) -> Result<()> {
let files_to_copy = vec![(
source_dir.join("netlify/_redirects"),
public_dir.join("_redirects"),
)];
for (source, destination) in files_to_copy {
fs::copy(source, destination)?;
}
let dirs_to_copy = vec![
2022-03-28 12:06:33 +00:00
(source_dir.join("assets"), &public_dir),
2021-12-13 23:50:38 +00:00
(source_dir.join("js"), &public_dir),
(build_dir.join("userstyles"), &public_dir),
];
for (source, destination) in dirs_to_copy {
Command::new("cp")
.arg("-r")
.arg(source)
.arg(destination)
.output()?;
}
Ok(())
}
}