Skip to content

Commit

Permalink
Add coloring for file selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Jun 10, 2021
1 parent e97aab4 commit b435b79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/cli/messages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import chalk from 'chalk';
import { LanguageId } from '../lib/deployment';
import { Languages } from '../lib/language';

export const info = (message: string): void => {
// eslint-disable-next-line no-console
Expand All @@ -15,3 +17,8 @@ export const error = (message: string): never => {
console.error(chalk.redBright.bold('X') + ' ' + chalk.red(message));
return process.exit(1);
};

export const printLanguage = (language: LanguageId): string =>
chalk
.hex(Languages[language].hexColor)
.bold(Languages[language].displayName);
9 changes: 4 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env node
import { promises as fs } from 'fs';
import { error, info, warn } from './cli/messages';
import { error, info, printLanguage, warn } from './cli/messages';
import { fileSelection, languageSelection } from './cli/selection';
import { LanguageId } from './lib/deployment';
import { Languages } from './lib/language';
import {
generateJsonsFromFiles,
generatePackage,
Expand Down Expand Up @@ -68,9 +67,9 @@ void (async () => {

for (const pkg of packages) {
pkg.scripts = await fileSelection(
`Select files to load with ${
Languages[pkg.language_id].displayName
}`,
`Select files to load with ${printLanguage(
pkg.language_id
)}`,
pkg.scripts
);
}
Expand Down

0 comments on commit b435b79

Please sign in to comment.