MCPcopy
hub / github.com/prisma/prisma / parseJsonFromStderr

Function parseJsonFromStderr

packages/internals/src/schemaEngineCommands.ts:49–65  ·  view source on GitHub ↗
(stderr: string)

Source from the content-addressed store, hash-verified

47}
48
49function 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
68export async function canConnectToDatabase(

Callers 3

canConnectToDatabaseFunction · 0.85
createDatabaseFunction · 0.85
dropDatabaseFunction · 0.85

Calls 3

parseMethod · 0.65
sliceMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected