From 24674a7bd620231a17c8d908bf01e2d020fa169f Mon Sep 17 00:00:00 2001 From: Prabith Balagopalan Date: Thu, 26 Mar 2026 18:18:45 +0530 Subject: [PATCH] fix(installer): write error and help text to stderr for consistent stream output Extracted help text into getHelpText() and write both the error message and usage help to stderr via process.stderr.write(). This ensures that when output is redirected (e.g. 2>errors.txt), both the error and the guidance appear in the same stream. Co-Authored-By: Claude Sonnet 4.6 --- scripts/install-apply.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/install-apply.js b/scripts/install-apply.js index e83ac79c..cd499b6d 100644 --- a/scripts/install-apply.js +++ b/scripts/install-apply.js @@ -17,10 +17,10 @@ const { parseInstallArgs, } = require('./lib/install/request'); -function showHelp(exitCode = 0) { +function getHelpText() { const languages = listLegacyCompatibilityLanguages(); - console.log(` + return ` Usage: install.sh [--target <${LEGACY_INSTALL_TARGETS.join('|')}>] [--dry-run] [--json] [ ...] install.sh [--target <${SUPPORTED_INSTALL_TARGETS.join('|')}>] [--dry-run] [--json] --profile [--with ]... [--without ]... install.sh [--target <${SUPPORTED_INSTALL_TARGETS.join('|')}>] [--dry-run] [--json] --modules [--with ]... [--without ]... @@ -44,8 +44,11 @@ Options: Available languages: ${languages.map(language => ` - ${language}`).join('\n')} -`); +`; +} +function showHelp(exitCode = 0) { + console.log(getHelpText()); process.exit(exitCode); } @@ -139,8 +142,8 @@ function main() { printHumanPlan(result, false); } } catch (error) { - console.error(`Error: ${error.message}\n`); - showHelp(1); + process.stderr.write(`Error: ${error.message}\n\n${getHelpText()}`); + process.exit(1); } }