feat(cli): improve changelog logging

This commit is contained in:
陈嘉涵
2020-01-15 13:11:20 +08:00
parent 67e2a2759c
commit a98e9b29f9
3 changed files with 20 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
import { join } from 'path';
import { ROOT } from '../common/constant';
import { logger, simplifyPath } from '../common/logger';
import { ora, slimPath } from '../common/logger';
import { createWriteStream, readFileSync } from 'fs-extra';
// @ts-ignore
import conventionalChangelog from 'conventional-changelog';
@@ -47,7 +47,7 @@ function transform(item: any) {
}
export async function changelog() {
logger.start('Generating changelog...');
const spinner = ora('Generating changelog...').start();
return new Promise(resolve => {
conventionalChangelog(
@@ -66,7 +66,7 @@ export async function changelog() {
)
.pipe(createWriteStream(DIST_FILE))
.on('close', () => {
logger.success(`Changelog generated successfully at ${simplifyPath(DIST_FILE)}`);
spinner.succeed(`Changelog generated at ${slimPath(DIST_FILE)}`);
resolve();
});
});

View File

@@ -1,3 +1,4 @@
import ora from 'ora';
import chalk from 'chalk';
import logger from 'signale';
import { ROOT } from '../common/constant';
@@ -35,8 +36,8 @@ export function getInteractiveLogger() {
return interactive;
}
export function simplifyPath(path: string) {
export function slimPath(path: string) {
return chalk.yellow(path.replace(ROOT, '.'));
}
export { logger };
export { ora, logger };