Impl copy mode in prepare_scripts sub command.
@@ -59,15 +59,33 @@ fn build_scripts(repos: Repos, root_dir: &Path, _scripts_dir: &Path) -> Result<(
Ok(())
}
-fn copy_scripts(_prebuild_image: &PathBuf, _scripts_dir: &Path) {}
+fn copy_scripts(prebuild_image: &PathBuf, scripts_dir: &Path) {
+ let mut target_dir = env::current_dir().expect("Get working dir failed");
+ target_dir.push(scripts_dir);
+ let temp_dir = "temp/";
+ let volumn_arg = format!("-v{}:/{}", target_dir.display().to_string(), temp_dir);
+ run_command(
+ "docker",
+ vec![
+ "run",
+ "--rm",
+ &volumn_arg,
+ &prebuild_image.display().to_string(),
+ "cp",
+ "-r",
+ "scripts/.",
+ temp_dir,
+ ],
+ )
+ .expect("Run docker cp failed");
+}
fn generate_script_deploy_config(_output_path: &Path) {}
fn build_godwoken_scripts(repo_url: Url, root_dir: &Path, repo_name: &str) -> Result<()> {
run_pull_code(repo_url, true, root_dir, repo_name)?;
- let mut target_dir = PathBuf::new();
- target_dir.push(root_dir);
+ let mut target_dir = PathBuf::from(root_dir);
target_dir.push(repo_name);
target_dir.push("c");
run_command("make", vec!["-C", &target_dir.display().to_string()]).expect("Run make failed");
@@ -85,8 +103,7 @@ fn build_godwoken_scripts(repo_url: Url, root_dir: &Path, repo_name: &str) -> Re
fn build_godwoken_polyjuice(repo_url: Url, root_dir: &Path, repo_name: &str) -> Result<()> {
run_pull_code(repo_url, true, root_dir, repo_name)?;
- let mut target_dir = PathBuf::new();
- target_dir.push(root_dir);
+ let mut target_dir = PathBuf::from(root_dir);
target_dir.push(repo_name);
run_command(
"make",
@@ -98,8 +115,7 @@ fn build_godwoken_polyjuice(repo_url: Url, root_dir: &Path, repo_name: &str) ->
fn build_clerkb(repo_url: Url, root_dir: &Path, repo_name: &str) -> Result<()> {
run_pull_code(repo_url, true, root_dir, repo_name)?;
- let mut target_dir = PathBuf::new();
- target_dir.push(root_dir);
+ let mut target_dir = PathBuf::from(root_dir);
target_dir.push(repo_name);
run_command("yarn", vec!["--cwd", &target_dir.display().to_string()]).expect("Run yarn failed");
run_command(
@@ -124,8 +140,7 @@ fn run_pull_code(
.to_owned();
repo.set_fragment(None);
- let mut target_dir = PathBuf::new();
- target_dir.push(root_dir);
+ let mut target_dir = PathBuf::from(root_dir);
target_dir.push(repo_name);
if target_dir.exists() && run_git_checkout(&target_dir, &commit).is_ok() {
