UNPKG

commit-vibes

Version:

A CLI tool to add vibes to your Git commit messages

53 lines (44 loc) • 1.44 kB
import chalk from "chalk"; import { intro } from "@clack/prompts"; import { checkCancellation, forceExit } from "./signal-handler.js"; export function showIntro() { console.clear(); intro(chalk.blue.bold("Welcome to Commit Vibes!")); } export function printStagedFiles(stagedFiles) { console.log(chalk.green("\nšŸ“‚ Staged files:")); console.log(chalk.gray(stagedFiles.map((file) => ` - ${file}`).join("\n"))); } export function printSpotifyTrack(track) { console.log(chalk.blue("\nšŸŽµ Now Playing:")); console.log(chalk.gray(` ${track.name} - ${track.artist}`)); } export function printRecentTracks(tracks) { console.log(chalk.blue("\nšŸŽµ No song currently playing")); console.log(chalk.gray("Recent tracks:")); tracks.forEach((track) => { console.log( chalk.gray(` • "${track.name}" - ${track.artist} (${track.playedAt})`) ); }); } export function printBanner(message) { console.log(chalk.yellow(message)); } export function handleError(message, error) { console.error(chalk.red(message)); if (error) console.error(chalk.dim(error.message)); process.exit(1); } export function exitIfCancelled(value) { if (value === null || value === undefined) { console.log(chalk.red("āŒ Commit canceled.")); process.exit(1); } } export function checkCancellationState() { if (checkCancellation()) { console.log(chalk.red("āŒ Operation cancelled")); forceExit(); } }