Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 7ecc50f

Browse files
greynewellclaude
andcommitted
fix: redirect npm install output to stderr for visibility
NPM often silences stdout for global installs. By writing progress and tool output to stderr, we ensure the user sees the installation status and the help menu immediately after install. Co-Authored-By: Grey Newell <greyshipscode@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Made-with: Cursor
1 parent 32d05e3 commit 7ecc50f

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

npm/install.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ async function main() {
125125
const destPath = path.join(binDir, binaryName);
126126

127127
if (fs.existsSync(destPath)) {
128-
console.log(`[uncompact] Binary already exists at ${destPath}`);
129128
return;
130129
}
131130

@@ -134,30 +133,31 @@ async function main() {
134133
try {
135134
release = await getRelease(version);
136135
} catch (err) {
137-
console.error(`[uncompact] Failed to fetch release: ${err.message}`);
138-
console.error(`[uncompact] You can install manually: go install github.com/${REPO_OWNER}/${REPO_NAME.toLowerCase()}@latest`);
136+
process.stderr.write(`[uncompact] Failed to fetch release: ${err.message}\n`);
137+
process.stderr.write(`[uncompact] You can install manually: go install github.com/${REPO_OWNER}/${REPO_NAME.toLowerCase()}@latest\n`);
139138
process.exit(0);
140139
}
141140

142141
const asset = release.assets.find((a) => a.name === assetName);
143142
if (!asset) {
144-
console.error(`[uncompact] No binary found for ${platform}/${arch} in release ${release.tag_name}`);
145-
console.error(`[uncompact] Available assets: ${release.assets.map((a) => a.name).join(", ")}`);
146-
console.error(`[uncompact] You can install manually: go install github.com/${REPO_OWNER}/${REPO_NAME.toLowerCase()}@latest`);
143+
process.stderr.write(`[uncompact] No binary found for ${platform}/${arch} in release ${release.tag_name}\n`);
144+
process.stderr.write(`[uncompact] Available assets: ${release.assets.map((a) => a.name).join(", ")}\n`);
145+
process.stderr.write(`[uncompact] You can install manually: go install github.com/${REPO_OWNER}/${REPO_NAME.toLowerCase()}@latest\n`);
147146
process.exit(0);
148147
}
149148

150-
console.log(`[uncompact] Downloading ${asset.name}...`);
149+
process.stderr.write(`[uncompact] Installing ${BINARY_NAME} ${release.tag_name} for ${platform}/${arch}...\n`);
150+
process.stderr.write(`[uncompact] Downloading ${asset.name}...\n`);
151151

152152
let buffer;
153153
try {
154154
buffer = await httpsGet(asset.browser_download_url);
155155
} catch (err) {
156-
console.error(`[uncompact] Failed to download: ${err.message}`);
156+
process.stderr.write(`[uncompact] Failed to download: ${err.message}\n`);
157157
process.exit(0);
158158
}
159159

160-
console.log(`[uncompact] Extracting...`);
160+
process.stderr.write(`[uncompact] Extracting...\n`);
161161

162162
try {
163163
if (platform === "windows") {
@@ -166,30 +166,31 @@ async function main() {
166166
extractTarGz(buffer, binDir, binaryName);
167167
}
168168
} catch (err) {
169-
console.error(`[uncompact] Failed to extract: ${err.message}`);
169+
process.stderr.write(`[uncompact] Failed to extract: ${err.message}\n`);
170170
process.exit(0);
171171
}
172172

173173
if (platform !== "windows") {
174174
fs.chmodSync(destPath, 0o755);
175175
}
176176

177-
console.log(`[uncompact] Installed to ${destPath}`);
178-
console.log();
177+
process.stderr.write(`[uncompact] Installed to ${destPath}\n\n`);
179178

180179
// Automatically install Claude Code hooks
181-
console.log("[uncompact] Configuring Claude Code hooks...");
180+
process.stderr.write("[uncompact] Configuring Claude Code hooks...\n");
182181
try {
183-
execFileSync(destPath, ["install", "--yes"], { stdio: "inherit" });
182+
// We redirect stdout to stderr to ensure visibility during npm install
183+
execFileSync(destPath, ["install", "--yes"], { stdio: ["inherit", process.stderr, "inherit"] });
184184
} catch (err) {
185-
console.error("[uncompact] Failed to automatically configure hooks. You can run it manually:");
186-
console.error(" uncompact install");
185+
process.stderr.write("[uncompact] Failed to automatically configure hooks. You can run it manually:\n");
186+
process.stderr.write(" uncompact install\n");
187187
}
188-
console.log();
188+
process.stderr.write("\n");
189189

190190
// Show help output after install
191191
try {
192-
execFileSync(destPath, [], { stdio: "inherit" });
192+
// We redirect stdout to stderr to ensure visibility during npm install
193+
execFileSync(destPath, [], { stdio: ["inherit", process.stderr, "inherit"] });
193194
} catch (err) {
194195
// Ignore errors from running the binary itself
195196
}

0 commit comments

Comments
 (0)