Skip to content

Commit d0c6ed5

Browse files
committed
fix: redirect helper output to stderr in install script
Command substitution was capturing info/warn/error messages from helper functions, causing the install script to fail when getting binary paths. - Redirect info(), warn(), and error() output to stderr in scripts/install.sh - Update tests to check stderr for helper function output
1 parent 271c581 commit d0c6ed5

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

scripts/install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ YELLOW='\033[1;33m'
1414
NC='\033[0m' # No Color
1515

1616
info() {
17-
echo -e "${GREEN}[info]${NC} $1"
17+
echo -e "${GREEN}[info]${NC} $1" >&2
1818
}
1919

2020
warn() {
21-
echo -e "${YELLOW}[warn]${NC} $1"
21+
echo -e "${YELLOW}[warn]${NC} $1" >&2
2222
}
2323

2424
error() {
25-
echo -e "${RED}[error]${NC} $1"
25+
echo -e "${RED}[error]${NC} $1" >&2
2626
exit 1
2727
}
2828

tests/scripts/install.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,28 @@ describe("install.sh", () => {
112112
});
113113

114114
describe("helper functions", () => {
115-
test("info() outputs green message", async () => {
115+
test("info() outputs green message to stderr", async () => {
116116
const result = await runScriptFunction('info "Test message"');
117117

118118
expect(result.exitCode).toBe(0);
119-
expect(result.stdout).toContain("Test message");
119+
expect(result.stderr).toContain("Test message");
120120
});
121121

122-
test("warn() outputs yellow message", async () => {
122+
test("warn() outputs yellow message to stderr", async () => {
123123
const result = await runScriptFunction('warn "Warning message"');
124124

125125
expect(result.exitCode).toBe(0);
126-
expect(result.stdout).toContain("Warning message");
126+
expect(result.stderr).toContain("Warning message");
127127
});
128128

129-
test("error() outputs red message and exits with 1", async () => {
129+
test("error() outputs red message to stderr and exits with 1", async () => {
130130
const script = `
131131
source "${SCRIPT_PATH}"
132132
error "Error message" || true
133133
`;
134134
const result = await runBash(script);
135135

136-
expect(result.stdout).toContain("Error message");
136+
expect(result.stderr).toContain("Error message");
137137
});
138138
});
139139

0 commit comments

Comments
 (0)