smaug_lib/sources/
dir_source.rs

1use crate::dependency::Dependency;
2use crate::source::Source;
3use log::*;
4use std::path::Path;
5use std::path::PathBuf;
6
7#[derive(Clone, Debug)]
8pub struct DirSource {
9    pub path: PathBuf,
10}
11
12impl Source for DirSource {
13    fn install(&self, dependency: &Dependency, destination: &Path) -> std::io::Result<()> {
14        let project_dir = destination.parent().unwrap();
15        let source = project_dir.join(self.path.to_path_buf());
16        let destination = destination.join(dependency.clone().name);
17        trace!(
18            "Installing directory from {} to {}",
19            source.display(),
20            destination.display()
21        );
22
23        crate::util::dir::copy_directory(&source, destination)?;
24
25        Ok(())
26    }
27}