Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support options.print_commands on Windows #26

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ fn modify_script(script: &String, options: &ScriptOptions) -> ScriptResult<Strin
script_lines.insert(insert_index, "set -x".to_string());
insert_index = insert_index + 1;
}
} else {
if !options.print_commands {
script_lines.insert(insert_index, "@echo off".to_string());
insert_index = insert_index + 1;
}
}

script_lines.insert(insert_index, cd_command);
Expand Down
9 changes: 9 additions & 0 deletions src/runner_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ fn modify_script_no_shebang_default_options() {

let cwd = current_dir().unwrap();
let mut expected_script = "".to_string();
if cfg!(windows) {
expected_script.push_str("@echo off\n");
}
expected_script.push_str("cd \"");
expected_script.push_str(cwd.to_str().unwrap());
expected_script.push_str("\"\necho test\n\n");
Expand All @@ -25,6 +28,7 @@ fn modify_script_no_shebang_default_options() {
assert_eq!(script, expected_script);
}

#[cfg(not(windows))]
#[test]
fn modify_script_with_shebang_default_options() {
let options = ScriptOptions::new();
Expand All @@ -49,6 +53,8 @@ fn modify_script_exit_on_error() {
let mut expected_script = "".to_string();
if !cfg!(windows) {
expected_script.push_str("set -e\n");
} else {
expected_script.push_str("@echo off\n");
}
expected_script.push_str("cd \"");
expected_script.push_str(cwd.to_str().unwrap());
Expand All @@ -66,6 +72,9 @@ fn modify_script_working_directory() {

let cwd = current_dir().unwrap();
let mut expected_script = "".to_string();
if cfg!(windows) {
expected_script.push_str("@echo off\n");
}
expected_script.push_str("cd \"");
expected_script.push_str(cwd.to_str().unwrap());
expected_script.push_str("\" && cd \"/usr/me/home\"\necho test\n\n");
Expand Down