import { enginesVersion , getEnginesPath } from '@prisma/engines' ; import { download } from '@prisma/fetch-engine' ; import type { Platform } from '@prisma/get-platform' ; import { getNodeAPIName } from '@prisma/get-platform' ; import { ClientEngineType } from '@prisma/sdk' ; import fs from 'fs' ; import path from 'path' ; param clientEngineType param platform export async function ensureTestClientQueryEngine ( clientEngineType , platform ) { const enginesPath = getEnginesPath ( ) ; const queryEngineLibraryPath = path . join ( enginesPath , getNodeAPIName ( platform , 'fs' ) ) ; const queryEngineBinaryPath = path . join ( enginesPath , `query-engine-${ platform }${ platform === 'windows' ? '.exe' : '' }` ) ; if ( clientEngineType === ClientEngineType . Library && ! fs . existsSync ( queryEngineLibraryPath ) ) { await download ( { binaries : { 'libquery-engine' : enginesPath , } , version : enginesVersion , } ) ; } else if ( clientEngineType === ClientEngineType . Binary && ! fs . existsSync ( queryEngineBinaryPath ) ) { await download ( { binaries : { 'query-engine' : enginesPath , } , version : enginesVersion , } ) ; } }