(invocationReply)
| 147 | } |
| 148 | |
| 149 | log(invocationReply) { |
| 150 | this.progress.remove() |
| 151 | |
| 152 | if (invocationReply.Payload) { |
| 153 | const response = JSON.parse(this.payloadToString(invocationReply.Payload)) |
| 154 | |
| 155 | writeText(JSON.stringify(response, null, 4)) |
| 156 | } |
| 157 | |
| 158 | if (invocationReply.LogResult) { |
| 159 | this.logger.blankLine() |
| 160 | writeText(style.aside('----------------------')) |
| 161 | this.logger.blankLine() |
| 162 | const logResult = Buffer.from( |
| 163 | invocationReply.LogResult, |
| 164 | 'base64', |
| 165 | ).toString() |
| 166 | const logResultLines = logResult.split('\n') |
| 167 | // Loop through and ensure the log that starts with "START" is always shown first |
| 168 | // and the log that starts with "REPORT" is always shown last |
| 169 | const startLog = logResultLines.find((line) => line.startsWith('START')) |
| 170 | const reportLog = logResultLines.find((line) => line.startsWith('REPORT')) |
| 171 | if (startLog) { |
| 172 | this.logger.aside(formatLambdaLogEvent(startLog)) |
| 173 | } |
| 174 | logResultLines.forEach((line) => { |
| 175 | if ( |
| 176 | !line.startsWith('START') && |
| 177 | !line.startsWith('END') && |
| 178 | !line.startsWith('REPORT') |
| 179 | ) { |
| 180 | this.logger.aside(formatLambdaLogEvent(line)) |
| 181 | } |
| 182 | }) |
| 183 | if (reportLog) { |
| 184 | this.logger.aside(formatLambdaLogEvent(reportLog)) |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | if (invocationReply.FunctionError) { |
| 189 | throw new ServerlessError( |
| 190 | 'Invoked function failed', |
| 191 | 'AWS_LAMBDA_INVOCATION_FAILED', |
| 192 | ) |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | export default AwsInvoke |
no test coverage detected