@robherley/actions-log-parser
A TypeScript library for parsing GitHub Actions log streams with ANSI color support, collapsible groups, and text formatting.
Installation
npm install @robherley/actions-log-parser
Usage
Basic Log Parsing
import { LogParser } from '@robherley/actions-log-parser';
const parser = new LogParser();
parser.add('##[group]Building project');
parser.add('npm install');
parser.add('npm run build');
parser.add('##[endgroup]');
const lines = parser.lines;
console.log(lines);
Handling Groups and Commands
import { LogParser, Command } from '@robherley/actions-log-parser';
const parser = new LogParser();
parser.add('##[group]Setup Phase');
parser.add('Setting up environment...');
parser.add('##[endgroup]');
parser.add('##[warning]This is a warning message');
parser.add('##[error]This is an error message');
console.log(parser.getVisibleLines())
parser.lines[0].group.open = true
console.log(parser.getVisibleLines())
Working with ANSI Colors
import { LogParser, Styles } from '@robherley/actions-log-parser';
const parser = new LogParser();
const styles = new Styles();
parser.add('\x1b[32mSuccess!\x1b[0m Build completed');
const line = parser.lines[0];
console.log(line.ansis)
Search
const parser = new LogParser();
parser.add('Building application...');
parser.add('Running tests...');
parser.add('Build complete!');
const matches = parser.setSearch('build');
console.log(matches)
Demo
See https://logs.reb.gg for an interactive demo.
License
MIT