From aae3a6c62d10c37886b2832f4932e6dbd20f816a Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 22 Oct 2026 03:45:25 +0800 Subject: [PATCH] doctor: at a terminal the used-for column is cut to the window width so rows never wrap; piped output stays whole --- cli/doctor.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/doctor.ts b/cli/doctor.ts index 7b2de04..612d04f 100644 --- a/cli/doctor.ts +++ b/cli/doctor.ts @@ -82,7 +82,15 @@ export async function run(args: Args): Promise { } if (args.has('json')) { printJson(r); return; } log('doctor', `storebound ${r.storebound} · ${r.runtime} · ${r.platform}${r.project ? ' · project config found' : ''}`); - console.log(textTable(['tool', 'status', 'version', 'needs', 'used for'], r.tools.map(t => [t.name, t.status === 'outdated' ? 'too old' : t.found ? (t.source === 'app' ? 'ok (app copy)' : 'ok') : 'missing', t.version ?? '', t.required ?? '', t.usedFor]))); + const rows = r.tools.map(t => [t.name, t.status === 'outdated' ? 'too old' : t.found ? (t.source === 'app' ? 'ok (app copy)' : 'ok') : 'missing', (t.version ?? '').slice(0, 16), t.required ?? '', t.usedFor]); + // at a terminal the last column is cut to the window width, so rows never wrap (piped output stays whole) + const cols = process.stdout.isTTY ? process.stdout.columns : 0; + if (cols) { + const w = (i: number) => Math.max(...[['tool', 'status', 'version', 'needs'][i]!, ...rows.map(x => x[i]!)].map(s => s.length)); + const room = cols - [0, 1, 2, 3].reduce((n, i) => n + w(i) + 2, 0) - 1; + for (const x of rows) if (x[4]!.length > room) x[4] = room > 8 ? `${x[4]!.slice(0, room - 1)}…` : ''; + } + console.log(textTable(['tool', 'status', 'version', 'needs', 'used for'], rows)); log('doctor', r.androidSdk.path ? `Android SDK: ${r.androidSdk.path} (from ${r.androidSdk.source})` : `Android SDK: not found (play build needs it). Checked: ${r.androidSdk.checked.join('; ')}`); const set = r.credentials.filter(c => c.status === 'set').map(c => c.key), ph = r.credentials.filter(c => c.status === 'placeholder').map(c => c.key);