mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 11:15:14 +00:00
print nice build summaries
This commit is contained in:
@@ -2,6 +2,7 @@ import { build as _build } from '../api/build';
|
||||
import colors from 'kleur';
|
||||
import { locations } from '../config';
|
||||
import validate_bundler from './utils/validate_bundler';
|
||||
import { repeat } from '../utils';
|
||||
|
||||
export function build(opts: { bundler?: string }) {
|
||||
const bundler = validate_bundler(opts.bundler);
|
||||
@@ -18,7 +19,20 @@ export function build(opts: { bundler?: string }) {
|
||||
});
|
||||
|
||||
emitter.on('build', event => {
|
||||
console.log(colors.inverse(`\nbuilt ${event.type}`));
|
||||
let banner = `built ${event.type}`;
|
||||
let c = colors.cyan;
|
||||
|
||||
const { warnings } = event.result;
|
||||
if (warnings.length > 0) {
|
||||
banner += ` with ${warnings.length} ${warnings.length === 1 ? 'warning' : 'warnings'}`;
|
||||
c = colors.yellow;
|
||||
}
|
||||
|
||||
console.log();
|
||||
console.log(c(`┌─${repeat('─', banner.length)}─┐`));
|
||||
console.log(c(`│ ${colors.bold(banner) } │`));
|
||||
console.log(c(`└─${repeat('─', banner.length)}─┘`));
|
||||
|
||||
console.log(event.result.print());
|
||||
});
|
||||
|
||||
@@ -30,8 +44,7 @@ export function build(opts: { bundler?: string }) {
|
||||
fulfil();
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(`${colors.bold.red(`> ${err.message}`)}`);
|
||||
process.exit(1);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user