Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
import commander from 'commander';
import chalk from 'chalk';
import didYouMean from 'didyoumean';
import Command from './command';
import { Commands } from '../extensions/extension';
import { migrate } from '../api/consumer';
import defaultHandleError from './default-error-handler';
import { empty, camelCase, first, isNumeric, buildCommandMessage, packCommand } from '../utils';
import loader from './loader';
import logger from '../logger/logger';
import { Analytics } from '../analytics/analytics';
import { SKIP_UPDATE_FLAG, TOKEN_FLAG, TOKEN_FLAG_NAME } from '../constants';
import globalFlags from './global-flags';
didYouMean.returnFirstMatch = true;
function logAndExit(msg: string, commandName, code = 0) {
process.stdout.write(`${msg}\n`, () => logger.exitAfterFlush(code, commandName));
}
function logErrAndExit(msg: Error | string, commandName: string) {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
if (msg.code) throw msg;
console.error(msg); // eslint-disable-line
logger.exitAfterFlush(1, commandName);
}
function parseSubcommandFromArgs(args: [any]) {
if (typeof first(args) === 'string') return first(args);
return null;
}