fix(cli/postinstall): print collision guidance to stderr and suggest 'coder' when VS Code's 'code' is on PATH

This commit is contained in:
James Peter
2025-08-30 10:52:06 +10:00
parent 25f12220fa
commit 09ebae92cc
+7 -7
View File
@@ -468,8 +468,8 @@ async function main() {
const list = Array.from(installedCmds).sort().join(', '); const list = Array.from(installedCmds).sort().join(', ');
console.log(`Commands installed (bun): ${list}`); console.log(`Commands installed (bun): ${list}`);
if (skippedCmds.length) { if (skippedCmds.length) {
for (const s of skippedCmds) console.log(`Commands skipped: ${s.name} (${s.reason})`); for (const s of skippedCmds) console.error(`Commands skipped: ${s.name} (${s.reason})`);
console.log('→ Use `coder` to run this tool.'); console.error('→ Use `coder` to run this tool.');
} }
// Final friendly usage hint // Final friendly usage hint
if (installedCmds.has('code')) { if (installedCmds.has('code')) {
@@ -513,19 +513,19 @@ async function main() {
ensureWrapper('code-exec', 'exec'); ensureWrapper('code-exec', 'exec');
if (collision) { if (collision) {
console.log('⚠ Detected existing `code` on PATH:'); console.error('⚠ Detected existing `code` on PATH:');
for (const p of others) console.log(` - ${p}`); for (const p of others) console.error(` - ${p}`);
if (globalBin) { if (globalBin) {
try { try {
if (existsSync(ourShim)) { if (existsSync(ourShim)) {
unlinkSync(ourShim); unlinkSync(ourShim);
console.log(`✓ Skipped global 'code' shim (removed ${ourShim})`); console.error(`✓ Skipped global 'code' shim (removed ${ourShim})`);
skippedCmds.push({ name: 'code', reason: `existing: ${others[0]}` }); skippedCmds.push({ name: 'code', reason: `existing: ${others[0]}` });
} }
} catch (e) { } catch (e) {
console.log(`⚠ Could not remove npm shim '${ourShim}': ${e.message}`); console.error(`⚠ Could not remove npm shim '${ourShim}': ${e.message}`);
} }
console.log('→ Use `coder` to run this tool.'); console.error('→ Use `coder` to run this tool.');
} else { } else {
console.log('Note: could not determine npm global bin; skipping alias creation.'); console.log('Note: could not determine npm global bin; skipping alias creation.');
} }