import * as util from "util" ; import * as run from "./index" ; /** simulates console.log to collect output from a running action */ export class OutputCollector { /** collects the received output */ content : string [ ] = [ ] ; /** appends to the output with a newline */ log ( ... args ) { const stringified = [ ] ; for ( const arg of args ) { if ( typeof arg === "string" ) { stringified . push ( arg ) ; } else { stringified . push ( util . inspect ( arg ) ) ; } } this . content . push ( stringified . join ( " " ) + "\n" ) ; } /** returns the "log" function to be used by actions */ logFn ( ) { return this . log . bind ( this ) ; } /** returns the currently accumulated output */ toString ( ) { return this . content . join ( "" ) ; } }