UNPKG

node-reporter-gha

Version:
29 lines 995 B
import { EOL } from 'node:os'; import { escapeData, escapeProperty } from './utils.mjs'; class Command { command; properties; message; constructor(command, properties, message) { this.command = command; this.properties = properties; this.message = message; } toString() { let cmdStr = `::${this.command}`; if (Object.keys(this.properties).length > 0) { const properties = Object.entries(this.properties) .filter(([key, val]) => Object.hasOwn(this.properties, key) && val) .map(([key, val]) => `${key}=${escapeProperty(val)}`) .join(','); cmdStr += ` ${properties}`; } cmdStr += `::${escapeData(this.message)}`; return cmdStr; } } export function issueCommand(command, properties = {}, message = '') { const cmd = new Command(command, properties, message); return cmd.toString() + EOL; } //# sourceMappingURL=command.mjs.map