43 lines
952 B
Rust
43 lines
952 B
Rust
//! The logic for files that need be directly copied over.
|
|
|
|
use std::{fs, path::Path, process::Command};
|
|
|
|
use color_eyre::Result;
|
|
|
|
/// Struct to contain functionality for copying.
|
|
pub struct Copy;
|
|
|
|
impl Copy {
|
|
/// Copy all the files to their respective destinations.
|
|
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![
|
|
(source_dir.join("assets"), &public_dir),
|
|
(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(())
|
|
}
|
|
}
|