diff --git a/index.js b/index.js index 831dadc..83b20df 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,7 @@ program .version(VERSION) .option('-y, --yes', 'Skip prompts and install all tools automatically') .option('--dry-run', 'Show what would be installed without actually installing') + .option('--verbose', 'Show raw install output from package manager commands') .option('--list', 'List all available tools grouped by category and exit') .option('--category ','Install only tools from a specific category') .parse(process.argv); @@ -212,7 +213,7 @@ async function main() { } // ── Step 6: Install ─────────────────────────── - await runInstaller(os, selectedToolNames); + await runInstaller(os, selectedToolNames, { verbose: options.verbose }); // ── Step 7: Done ────────────────────────────── console.log(''); diff --git a/src/installer.js b/src/installer.js index 21cdaee..c625a77 100644 --- a/src/installer.js +++ b/src/installer.js @@ -20,9 +20,11 @@ const logger = require('./logger'); * * @param {{ id: string, label: string, scriptPath: string }} osInfo - OS descriptor from detectOS() * @param {string[]} selectedTools - Array of tool names to install (e.g. ['git', 'nodejs']) + * @param {{ verbose?: boolean }} [options] - Installer behavior flags */ -async function runInstaller(osInfo, selectedTools) { +async function runInstaller(osInfo, selectedTools, options = {}) { const scriptPath = path.join(__dirname, '..', osInfo.scriptPath); + const stdio = options.verbose ? 'inherit' : 'pipe'; logger.info(`Running installer for ${chalk.bold(osInfo.label)}`); logger.info(`Package manager: ${chalk.bold(osInfo.packageManager)}\n`); @@ -41,12 +43,12 @@ async function runInstaller(osInfo, selectedTools) { '-ExecutionPolicy', 'Bypass', '-File', scriptPath, '-Tool', tool, - ], { stdio: 'pipe' }); + ], { stdio }); } else { // macOS / Linux: run shell script // Ensure the script is executable first await execa('chmod', ['+x', scriptPath]); - await execa('bash', [scriptPath, tool], { stdio: 'pipe' }); + await execa('bash', [scriptPath, tool], { stdio }); } spinner.succeed(chalk.green(`Installed: ${chalk.bold(tool)}`)); diff --git a/tests/installer.test.js b/tests/installer.test.js index 93b2645..51ec825 100644 --- a/tests/installer.test.js +++ b/tests/installer.test.js @@ -88,6 +88,18 @@ describe('runInstaller — Windows', () => { expect(args).toContain('-Tool'); expect(args).toContain('nodejs'); }); + + test('uses inherited stdio when verbose mode is enabled', async () => { + await runInstaller(windowsOS, ['git'], { verbose: true }); + const psCalls = execa.mock.calls.filter((c) => c[0] === 'powershell'); + expect(psCalls[0][2]).toMatchObject({ stdio: 'inherit' }); + }); + + test('uses piped stdio by default', async () => { + await runInstaller(windowsOS, ['git']); + const psCalls = execa.mock.calls.filter((c) => c[0] === 'powershell'); + expect(psCalls[0][2]).toMatchObject({ stdio: 'pipe' }); + }); }); // ─────────────────────────────────────────────────────────────────────────────