Explorar el Código

fix(install): support stdin execution

xcad hace 1 mes
padre
commit
1b527aa79b
Se han modificado 2 ficheros con 16 adiciones y 1 borrados
  1. 1 1
      scripts/install.sh
  2. 15 0
      tests/test_install_script.py

+ 1 - 1
scripts/install.sh

@@ -371,6 +371,6 @@ Uninstall:
 EOF
 }
 
-if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
+if [[ "${BASH_SOURCE[0]-$0}" == "$0" ]]; then
   main "$@"
 fi

+ 15 - 0
tests/test_install_script.py

@@ -35,3 +35,18 @@ printf '%s\\n%s\\n%s\\n' "$INSTALL_VERSION" "$DISTRO_ID" "$DISTRO_VERSION"
 
     assert result.returncode == 0, result.stderr
     assert result.stdout.splitlines() == ["latest", "ubuntu", "24.04"]
+
+
+def test_install_script_runs_from_stdin_with_nounset() -> None:
+    """Regression test for stdin execution via `curl ... | bash`."""
+    result = subprocess.run(
+        ["bash", "-s", "--", "--help"],
+        cwd=REPO_ROOT,
+        input=INSTALL_SCRIPT.read_text(encoding="utf-8"),
+        capture_output=True,
+        text=True,
+        check=False,
+    )
+
+    assert result.returncode == 0, result.stderr
+    assert "Install the boilerplates CLI from GitHub releases via pipx." in result.stdout