Skip to content

Commit

Permalink
remove repeated type
Browse files Browse the repository at this point in the history
  • Loading branch information
yukukotani committed Mar 8, 2021
1 parent e33df10 commit e905cb2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions vti/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Command, Option } from 'commander';
import { diagnostics, logLevels } from './commands/diagnostics';
import { diagnostics, LogLevel, logLevels } from './commands/diagnostics';

function getVersion(): string {
const { version }: { version: string } = require('../package.json');
return `v${version}`;
}

function validateLogLevel(logLevelInput: unknown): logLevelInput is LogLevel {
return typeof logLevelInput === 'string' && (logLevels as ReadonlyArray<string>).includes(logLevelInput);
}

(async () => {
const program = new Command();
program.name('vti').description('Vetur Terminal Interface').version(getVersion());
Expand All @@ -21,12 +25,7 @@ function getVersion(): string {
)
.action(async (workspace, options) => {
const logLevelOption: unknown = options.logLevel;
if (
logLevelOption !== 'ERROR' &&
logLevelOption !== 'WARN' &&
logLevelOption !== 'INFO' &&
logLevelOption !== 'HINT'
) {
if (!validateLogLevel(logLevelOption)) {
throw new Error(`Invalid log level: ${logLevelOption}`);
}
await diagnostics(workspace, logLevelOption);
Expand Down

0 comments on commit e905cb2

Please # to comment.