doctor: at a terminal the used-for column is cut to the window width so rows never wrap; piped output stays whole
This commit is contained in:
parent
600b6893e5
commit
aae3a6c62d
1 changed files with 9 additions and 1 deletions
|
|
@ -82,7 +82,15 @@ export async function run(args: Args): Promise<void> {
|
|||
}
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue