Skip to content

Commit

Permalink
fix(engine): Fixed cannot find the query engine binary #285
Browse files Browse the repository at this point in the history
  • Loading branch information
Seven Du committed Nov 27, 2023
1 parent cc7ad64 commit 3331bf9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions bin/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ extension WriteLibrary on PrismaDartClientGenerator {

// Write to file.
output.writeAsStringSync(formatted, mode: FileMode.write);

// Copy binary engine file.
final executable =
options.binaryPaths?.queryEngine?.entries.firstOrNull?.value;
if (executable != null) {
File(executable).copySync(
path.join(path.dirname(output.path), path.basename(executable)),
);
}
}

/// Resolve the output path
Expand Down
8 changes: 7 additions & 1 deletion lib/binary_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ class BinaryEngine extends UniversalEngine implements Engine {
if (file.existsSync()) {
return file.path;
}

final defaultFile = File(path.join(directory, 'prisma-query-engine'));
if (defaultFile.existsSync()) {
return defaultFile.path;
}
}

throw PrismaInitializationException(
message: 'Cannot find the query engine binary (Basename: $basename)',
message:
'Cannot find the query engine binary (Basename: $basename | prisma-query-engine)',
engine: this);
}

Expand Down

0 comments on commit 3331bf9

Please sign in to comment.