UNPKG

gha-utils

Version:

A minimalistic utility package for developing GitHub Actions

59 lines (58 loc) 1.54 kB
import os from "node:os"; /** * Logs an information message in GitHub Actions. * * @param message - The information message to log. */ export function logInfo(message) { process.stdout.write(`${message}${os.EOL}`); } /** * Logs a debug message in GitHub Actions. * * @param message - The debug message to log. */ export function logDebug(message) { process.stdout.write(`::debug::${message}${os.EOL}`); } /** * Logs a warning message in GitHub Actions. * * @param message - The warning message to log. */ export function logWarning(message) { process.stdout.write(`::warning::${message}${os.EOL}`); } /** * Logs an error message in GitHub Actions. * * @param err - The error, which can be of any type. */ export function logError(err) { const message = err instanceof Error ? err.message : String(err); process.stdout.write(`::error::${message}${os.EOL}`); } /** * Logs a command along with its arguments in GitHub Actions. * * @param command - The command to log. * @param args - The arguments of the command. */ export function logCommand(command, ...args) { const message = [command, ...args].join(" "); process.stdout.write(`[command]${message}${os.EOL}`); } /** * Begins a log group in GitHub Actions. * * @param name - The name of the log group. */ export function beginLogGroup(name) { process.stdout.write(`::group::${name}${os.EOL}`); } /** * Ends the current log group in GitHub Actions. */ export function endLogGroup() { process.stdout.write(`::endgroup::${os.EOL}`); }