Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(install): guard empty prefix_args expansion on macOS Bash 3.2 under set -u (#1061)

Arian Pashae68b9fa489b0c
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d317a4eb4..06d3eec8c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -317,8 +317,8 @@ jobs:
- run: npm run verify:keyed-archive
- run: npm run verify:asset-catalog
- run: npm run verify:macos-bundle
- - name: Native compiled NIB hierarchy regressions
- run: npm run test:focused -- tests/boundary/filesystem/nibNativeHierarchy.test.ts tests/boundary/filesystem/interfaceBuilderBundle.test.ts
+ - name: Native installer and compiled NIB hierarchy regressions
+ run: npm run test:focused -- tests/boundary/filesystem/installScript.test.ts tests/boundary/filesystem/nibNativeHierarchy.test.ts tests/boundary/filesystem/interfaceBuilderBundle.test.ts
- name: Real binary metadata and Interface Builder integration
run: npm run verify:apple-dispatch && npm run verify:interface-builder
- name: Native plist CLI selection regressions
diff --git a/install.sh b/install.sh
index c236fc8ab..d05969484 100755
--- a/install.sh
+++ b/install.sh
@@ -107,7 +107,7 @@ if [[ "$dry_run" == true ]]; then
fi
printf 'Installing %s@%s...\n' "$PACKAGE" "$version"
-npm install --global "${prefix_args[@]}" "$PACKAGE@$version" || fail "npm could not install REA. Check registry access and npm permissions, then retry."
+npm install --global ${prefix_args[@]+"${prefix_args[@]}"} "$PACKAGE@$version" || fail "npm could not install REA. Check registry access and npm permissions, then retry."
[[ -x "$install_bin" ]] || fail "npm completed without installing the rea command. Check the npm global bin directory and PATH, then retry."
installed_version="$("$install_bin" --version 2>/dev/null | tr -d '[:space:]')" || fail "the installed REA version could not be read. Reinstall the requested version, then retry."
[[ "$installed_version" == "$version" ]] || fail "installed version $installed_version does not match $version. Reinstall the requested version, then retry."
diff --git a/tests/boundary/filesystem/installScript.test.ts b/tests/boundary/filesystem/installScript.test.ts
index 3abdf6a4f..57450fee4 100644
--- a/tests/boundary/filesystem/installScript.test.ts
+++ b/tests/boundary/filesystem/installScript.test.ts
@@ -172,6 +172,22 @@ describe("curl installer scenarios", { timeout: 20_000 }, () => {
});
});
+describe("native macOS installer", { timeout: 20_000 }, () => {
+ it("installs on Darwin with an empty prefix argument array", async () => {
+ const fixture = await createFixture();
+ const result = await runInstaller(fixture, ["--version", "0.3.0"], {
+ FAKE_PLATFORM: "Darwin",
+ FAKE_NPM_PREFIX: join(fixture.home, "npm global prefix"),
+ });
+ expect(result.stdout).toContain("REA 0.3.0 is installed");
+ expect(await readFile(fixture.npmLog, "utf8")).toBe(
+ "prefix --global\ninstall --global [email protected]\n",
+ );
+ expect(await readFile(fixture.reaLog, "utf8")).toBe("--version\n");
+ expect(await readdir(fixture.temporary)).toEqual([]);
+ });
+});
+
describe("installer semantic version parsing", { timeout: 20_000 }, () => {
it.each(["1.2.3-01"])(
"rejects malformed semantic versions before invoking npm: %s",
@@ -309,6 +325,7 @@ printf '%s\n' "$*" >> "$FAKE_NPM_LOG"
[ "$1" = "prefix" ] && { [ "\${FAKE_NPM_PREFIX_FAIL:-}" = "1" ] && exit 1; printf '%s\n' "$FAKE_NPM_PREFIX"; exit 0; }
[ "\${FAKE_NPM_FAIL:-}" = "1" ] && exit 1
prefix="$HOME/.local"
+[ "\${FAKE_PLATFORM:-Linux}" = "Darwin" ] && prefix="$FAKE_NPM_PREFIX"
while [ "$#" -gt 0 ]; do
if [ "$1" = "--prefix" ]; then shift; prefix="$1"; fi
shift