feat(dev-infra): migrate merge tool to use new logging system (#37422)

Migrate the merge tool in ng-dev to use new logging system rather
than directly calling console.* to create a better experience
for users.

PR Close #37422
This commit is contained in:
Joey Perrott
2020-05-20 14:48:50 -07:00
committed by atscott
parent 9078ca557e
commit d37c723951
3 changed files with 28 additions and 25 deletions

View File

@ -6,8 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import chalk from 'chalk';
import {Arguments, Argv} from 'yargs';
import {error, red, yellow} from '../../utils/console';
import {GITHUB_TOKEN_GENERATE_URL, mergePullRequest} from './index';
/** Builds the options for the merge command. */
@ -22,10 +24,9 @@ export function buildMergeCommand(yargs: Argv) {
export async function handleMergeCommand(args: Arguments) {
const githubToken = args.githubToken || process.env.GITHUB_TOKEN || process.env.TOKEN;
if (!githubToken) {
console.error(
chalk.red('No Github token set. Please set the `GITHUB_TOKEN` environment variable.'));
console.error(chalk.red('Alternatively, pass the `--github-token` command line flag.'));
console.error(chalk.yellow(`You can generate a token here: ${GITHUB_TOKEN_GENERATE_URL}`));
error(red('No Github token set. Please set the `GITHUB_TOKEN` environment variable.'));
error(red('Alternatively, pass the `--github-token` command line flag.'));
error(yellow(`You can generate a token here: ${GITHUB_TOKEN_GENERATE_URL}`));
process.exit(1);
}