Have rebar3.cmd work on a Windows CMD shell (#151)

3585096 · Paulo F. Oliveira · 2022-12-01 19:16

7 files +66 -2
Message
{commit_body(@commit)}

Files changed

modified .github/workflows/windows.yml
+11 −0
@@ -70,6 +70,17 @@ jobs:
70 70 if: ${{matrix.combo.gleam-version}}
71 71 - name: rebar3 version (action)
72 72 run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}"
73 + - name: Run rebar3 and rebar3.cmd
74 + run: |
75 + # Should not fail
76 + rebar3 version
77 + rebar3.cmd version
78 + if: ${{matrix.combo.rebar3-version}}
79 + - name: rebar3 from Rust
80 + run: |
81 + cd test-projects/rust_rebar3_cmd
82 + cargo test -- --nocapture
83 + if: ${{matrix.combo.rebar3-version}}
73 84 - name: mix version and help (CLI)
74 85 run: |
75 86 mix -v
modified dist/install-rebar3.ps1
+3 −1
@@ -7,6 +7,7 @@ Set-Location ${Env:RUNNER_TEMP}
7 7 $FILE_INPUT="rebar3"
8 8 $FILE_OUTPUT="rebar3"
9 9 $FILE_OUTPUT_PS1="rebar3.ps1"
10 +$FILE_OUTPUT_CMD="rebar3.cmd"
10 11 $DIR_FOR_BIN=".setup-beam/rebar3"
11 12
12 13 $ProgressPreference="SilentlyContinue"
@@ -22,8 +23,9 @@ $ProgressPreference="Continue"
22 23 New-Item "${DIR_FOR_BIN}/bin" -ItemType Directory | Out-Null
23 24 Move-Item "${FILE_OUTPUT}" "${DIR_FOR_BIN}/bin"
24 25 Write-Output "& escript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} `${args}" | Out-File -FilePath "${FILE_OUTPUT_PS1}" -Encoding utf8 -Append
25 type ${FILE_OUTPUT_PS1}
26 +Write-Output "@echo off`r`nescript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} %*" | Out-File -FilePath "${FILE_OUTPUT_CMD}" -Encoding utf8 -Append
26 27 Move-Item "${FILE_OUTPUT_PS1}" "${DIR_FOR_BIN}/bin"
28 +Move-Item "${FILE_OUTPUT_CMD}" "${DIR_FOR_BIN}/bin"
27 29 Write-Output "Installed rebar3 version${REBAR3_NIGHTLY} follows"
28 30 & "${DIR_FOR_BIN}/bin/rebar3" "version" | Write-Output
29 31
modified src/install-rebar3.ps1
+3 −1
@@ -7,6 +7,7 @@ Set-Location ${Env:RUNNER_TEMP}
7 7 $FILE_INPUT="rebar3"
8 8 $FILE_OUTPUT="rebar3"
9 9 $FILE_OUTPUT_PS1="rebar3.ps1"
10 +$FILE_OUTPUT_CMD="rebar3.cmd"
10 11 $DIR_FOR_BIN=".setup-beam/rebar3"
11 12
12 13 $ProgressPreference="SilentlyContinue"
@@ -22,8 +23,9 @@ $ProgressPreference="Continue"
22 23 New-Item "${DIR_FOR_BIN}/bin" -ItemType Directory | Out-Null
23 24 Move-Item "${FILE_OUTPUT}" "${DIR_FOR_BIN}/bin"
24 25 Write-Output "& escript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} `${args}" | Out-File -FilePath "${FILE_OUTPUT_PS1}" -Encoding utf8 -Append
25 type ${FILE_OUTPUT_PS1}
26 +Write-Output "@echo off`r`nescript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} %*" | Out-File -FilePath "${FILE_OUTPUT_CMD}" -Encoding utf8 -Append
26 27 Move-Item "${FILE_OUTPUT_PS1}" "${DIR_FOR_BIN}/bin"
28 +Move-Item "${FILE_OUTPUT_CMD}" "${DIR_FOR_BIN}/bin"
27 29 Write-Output "Installed rebar3 version${REBAR3_NIGHTLY} follows"
28 30 & "${DIR_FOR_BIN}/bin/rebar3" "version" | Write-Output
29 31
added test-projects/rust_rebar3_cmd/.gitignore
+2 −0
@@ -0,0 +1,2 @@
1 +/target/
2 +main
added test-projects/rust_rebar3_cmd/Cargo.lock
+7 −0
@@ -0,0 +1,7 @@
1 +# This file is automatically @generated by Cargo.
2 +# It is not intended for manual editing.
3 +version = 3
4 +
5 +[[package]]
6 +name = "rust_rebar3_cmd"
7 +version = "0.1.0"
added test-projects/rust_rebar3_cmd/Cargo.toml
+8 −0
@@ -0,0 +1,8 @@
1 +[package]
2 +name = "rust_rebar3_cmd"
3 +version = "0.1.0"
4 +edition = "2021"
5 +
6 +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 +
8 +[dependencies]
added test-projects/rust_rebar3_cmd/src/main.rs
+32 −0
@@ -0,0 +1,32 @@
1 +use std::env;
2 +use std::process;
3 +use std::string;
4 +
5 +// an example function...
6 +fn main() {
7 + let key = "PATH";
8 + match env::var(key) {
9 + Ok(val) => println!("{key}: {val:?}"),
10 + Err(e) => println!("couldn't interpret {key}: {e}"),
11 + }
12 +}
13 +
14 +#[allow(dead_code)]
15 +fn rebar3_cmd_version() -> Result<String, string::FromUtf8Error> {
16 + println!("going for rebar3.cmd");
17 + let output = process::Command::new("rebar3.cmd")
18 + .arg("version")
19 + .output()
20 + .expect("error");
21 + return String::from_utf8(output.stdout);
22 +}
23 +
24 +#[cfg(test)]
25 +mod tests {
26 + use super::*;
27 +
28 + #[test]
29 + fn it_works() {
30 + rebar3_cmd_version().unwrap();
31 + }
32 +}

Parents: b980a5a