or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-2/

Terminal Color Formatter

A terminal color formatting utility that works across different JavaScript environments, including those where the Node.js process object may not be available.

Capabilities

Environment Detection

  • Detects if color support is available in the current environment, returning true when running in a Node.js terminal with TTY support and false otherwise @test
  • When the process object is undefined (browser environment), color support detection returns false without throwing an error @test
  • When process.stdout is undefined but process exists, color support detection handles this gracefully and returns false @test

Color Formatting

  • Applies red color formatting to text when colors are supported @test
  • Returns plain text without ANSI codes when colors are not supported @test

Implementation

@generates

API

/**
 * Checks if the current environment supports terminal colors.
 * Safely handles missing process object.
 *
 * @returns {boolean} true if colors are supported, false otherwise
 */
function isColorSupported() {
  // IMPLEMENTATION HERE
}

/**
 * Formats text with red color when supported.
 *
 * @param {string} text - The text to format
 * @returns {string} Formatted text with ANSI codes if supported, plain text otherwise
 */
function red(text) {
  // IMPLEMENTATION HERE
}

module.exports = {
  isColorSupported,
  red
};

Dependencies { .dependencies }

picocolors { .dependency }

Provides terminal color formatting with defensive programming patterns for missing process object.