< Summary - Envilder CLI

Information
Class: src/envilder/core/infrastructure/github/GitHubActionsLogger.ts
Assembly: Default
File(s): src/envilder/core/infrastructure/github/GitHubActionsLogger.ts
Tag: 561_41292037308
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 37
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/envilder/core/infrastructure/github/GitHubActionsLogger.ts

#LineLine coverage
 1import type { ILogger } from '../../domain/ports/ILogger.js';
 2
 3/**
 4 * Logger for the GitHub Actions runner, which reads every output line as a
 5 * possible workflow command. Messages can carry input-derived text (file
 6 * names, secret references), so each one is written as a single inert line:
 7 * otherwise a value such as `x\n::stop-commands::t` would switch off command
 8 * processing before the `::add-mask::` registrations that follow.
 9 */
 10export class GitHubActionsLogger implements ILogger {
 4211  constructor(private readonly inner: ILogger) {}
 12
 13  info(message: string): void {
 4414    this.inner.info(toInertLine(message));
 15  }
 16
 17  warn(message: string): void {
 118    this.inner.warn(toInertLine(message));
 19  }
 20
 21  error(message: string): void {
 2922    this.inner.error(toInertLine(message));
 23  }
 24}
 25
 26function toInertLine(message: string): string {
 7427  return (
 28    message
 29      .replace(/\r/g, '\\r')
 30      .replace(/\n/g, '\\n')
 31      // Legacy `##[command]` syntax is recognized anywhere in a line.
 32      .replace(/##\[/g, '#\\#[')
 33      // `::command::` is recognized at the start, after whitespace as .NET
 34      // TrimStart sees it, which also includes NEL (U+0085).
 35      .replace(/^([\s\u0085]*)::/, '$1\\::')
 36  );
 37}

Methods/Properties

constructor
info
warn
error
toInertLine