(responseData: Record<string, unknown>, responseSessionDir: string)
| 715 | } |
| 716 | |
| 717 | export async function writeResponse(responseData: Record<string, unknown>, responseSessionDir: string): Promise<void> { |
| 718 | |
| 719 | const responseFile = path.join(responseSessionDir, 'response.log'); |
| 720 | const responseLockFile = path.join(responseSessionDir, 'response.lock'); |
| 721 | if (!fs.existsSync(responseFile) || !fs.existsSync(responseLockFile)) { |
| 722 | throw ('Received a request from R for response' + |
| 723 | 'to a session directiory that does not contain response.log or response.lock: ' + |
| 724 | responseSessionDir); |
| 725 | } |
| 726 | const responseString = JSON.stringify(responseData); |
| 727 | console.info('[writeResponse] Started'); |
| 728 | console.info(`[writeResponse] responseData ${responseString}`); |
| 729 | console.info(`[writeRespnse] responseFile: ${responseFile}`); |
| 730 | await fs.writeFile(responseFile, responseString); |
| 731 | responseTimeStamp = Date.now(); |
| 732 | await fs.writeFile(responseLockFile, `${responseTimeStamp}\n`); |
| 733 | } |
| 734 | |
| 735 | export async function writeSuccessResponse(responseSessionDir: string): Promise<void> { |
| 736 | await writeResponse({ result: true }, responseSessionDir); |
no outgoing calls
no test coverage detected