dsl-toolkit/dsl-toolkit

View on GitHub
packages/cowlog/src/lib/logger/parser/after-print-commands.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
module.exports = (commands, afterPrintCommandOrder,loggerModule,exitState, retv, data, logEntry) => {
  afterPrintCommandOrder.forEach(command=>{
    if(command === 'last' && commands.command.has(command)){
      loggerModule.runtimeVariables.lastLogs = []
      loggerModule.runtimeVariables.lastLogs.push(logEntry)
    }

    if(command === 'lasts' && commands.command.has('lasts')){
      if(!exitState.lastsed){
        loggerModule.runtimeVariables.lastLogs = loggerModule.runtimeVariables.lastLogs || []
        loggerModule.runtimeVariables.lastLogs.push(logEntry)
        exitState.lastsed = true
      }
    }

    if(command === 'return' && commands.command.has(command)){
      retv.retv = data.data.returnArrayChunks[0][data.data.returnArrayChunks[0].length-1]
    }

    if(command === 'die' && commands.command.has(command)){
      exitState.dead = true
    }
  })
}