Commit dc928793 authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

feat: Prepare code for executing binaries

parent 02b99718
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ pub fn run(
                            // TODO: Check that URL exists
                            // TODO: Download binary to temp directory
                            // TODO: Verify binary checksum
                            // TODO: Verify binary is executable (https://docs.rs/is_executable/latest/is_executable/)
                            unimplemented!("Remote binary modules are not supported yet");
                        }
                        | _ => unimplemented!("Only HTTP, HTTPS, and SSH are currently supported for remote binary modules"),
@@ -76,6 +77,7 @@ pub fn run(
                    | ModuleUri::File(value) => match value.try_exists() {
                        | Ok(true) => {
                            let path = value.into_os_string().into_string().unwrap();
                            // TODO: Verify binary is executable (https://docs.rs/is_executable/latest/is_executable/)
                            debug!(module = module.name, path, "=> {} Local binary", Label::found());
                        }
                        | _ => {
+9 −1
Original line number Diff line number Diff line
@@ -1162,8 +1162,16 @@ impl StringTemplate {
    }
}
/// Add forward slash to end of folder path
pub fn add_dot_slash(path: PathBuf) -> PathBuf {
    if path.starts_with("./") {
        path.to_path_buf()
    } else {
        PathBuf::from(format!("./{}", path.display()))
    }
}
/// Add forward slash to end of folder path
pub fn add_forward_slash(path: PathBuf) -> PathBuf {
    if path.is_dir() {
    if path.is_dir() && !path.ends_with("/") {
        PathBuf::from(format!("{}/", path.display()))
    } else {
        path.to_path_buf()
+10 −0
Original line number Diff line number Diff line
@@ -4,10 +4,20 @@ use std::path::{Path, PathBuf};

const FIXTURES: &str = "../tests/fixtures";

#[test]
fn test_add_dot_slash() {
    assert_eq!(add_dot_slash(PathBuf::from("foo")), PathBuf::from("./foo"));
    assert_eq!(add_dot_slash(PathBuf::from("./foo")), PathBuf::from("./foo"));
    assert_eq!(add_dot_slash(PathBuf::from("foo/bar")), PathBuf::from("./foo/bar"));
    assert_eq!(add_dot_slash(PathBuf::from("foo/bar.json")), PathBuf::from("./foo/bar.json"));
}

#[test]
fn test_add_forward_slash() {
    assert_eq!(add_forward_slash(PathBuf::from("foo")), PathBuf::from("foo/"));
    assert_eq!(add_forward_slash(PathBuf::from("foo/")), PathBuf::from("foo/"));
    assert_eq!(add_forward_slash(PathBuf::from("foo/bar")), PathBuf::from("foo/bar/"));
    assert_eq!(add_forward_slash(PathBuf::from("foo/bar/")), PathBuf::from("foo/bar/"));
    assert_eq!(add_forward_slash(PathBuf::from("foo/bar.json")), PathBuf::from("foo/bar.json"));
}