Skip to content

Commit

Permalink
Windows directory copy (#292)
Browse files Browse the repository at this point in the history
* windows doesn't have "ls" on the path so make a test for windows that tests for a command in the path

* implement windows specific implementation

* remove dead code

* fix formatting

* Add a test for xcopy on windows
  • Loading branch information
martintc committed Dec 19, 2022
1 parent abc9758 commit 16336ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/src/actions/directory/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ impl DirectoryCopy {}

impl DirectoryAction for DirectoryCopy {}

#[cfg(target_family = "windows")]
impl Action for DirectoryCopy {
fn plan(&self, manifest: &Manifest, _context: &Contexts) -> anyhow::Result<Vec<Step>> {
let from: String = self.resolve(manifest, &self.from).display().to_string();

Ok(vec![Step {
atom: Box::new(Exec {
command: String::from("Xcopy"),
arguments: vec!["/E".to_string(), "/I".to_string(), from, self.to.clone()],
..Default::default()
}),
initializers: vec![],
finalizers: vec![],
}])
}
}

#[cfg(target_family = "unix")]
impl Action for DirectoryCopy {
fn plan(&self, manifest: &Manifest, _context: &Contexts) -> anyhow::Result<Vec<Step>> {
let from: String = self.resolve(manifest, &self.from).display().to_string();
Expand Down
10 changes: 10 additions & 0 deletions lib/src/steps/initializers/command_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ mod tests {
assert_eq!(true, result.is_ok());
assert_eq!(true, result.unwrap());
}

#[cfg(target_family = "windows")]
#[test]
fn return_true_windows_xcopy() {
let initializer = CommandFound("Xcopy");
let result = initializer.initialize();

assert_eq!(true, result.is_ok());
assert_eq!(true, result.unwrap());
}

#[cfg(target_family = "unix")]
#[test]
Expand Down

0 comments on commit 16336ce

Please sign in to comment.