(stderr: string)
| 47 | } |
| 48 | |
| 49 | function parseJsonFromStderr(stderr: string): SchemaEngineLogLine[] { |
| 50 | // split by new line |
| 51 | const lines = stderr.split(/\r?\n/).slice(1) // Remove first element |
| 52 | const logs: any = [] |
| 53 | |
| 54 | for (const line of lines) { |
| 55 | const data = String(line) |
| 56 | try { |
| 57 | const json: SchemaEngineLogLine = JSON.parse(data) |
| 58 | logs.push(json) |
| 59 | } catch (e) { |
| 60 | throw new Error(`Could not parse schema engine response: ${e}`) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | return logs |
| 65 | } |
| 66 | |
| 67 | // could be refactored with engines using JSON RPC instead and just passing the schema |
| 68 | export async function canConnectToDatabase( |
no test coverage detected