Skip to content

Commit

Permalink
fix: ensure package path is correctly resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jan 28, 2025
1 parent b03e0ce commit b6c0bf7
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/ffi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ function getPlatformArchSpecificPackage() {

const packagePath = `${platformArchSpecificPackage}/package.json`;
try {
require.resolve(packagePath);
return platformArchSpecificPackage;
let resolvedPackagePath = require.resolve(packagePath);
resolvedPackagePath = resolvedPackagePath.replace('/package.json', '');
return resolvedPackagePath;
} catch (e) {
throw new Error(
`Couldn't find npm package ${platformArchSpecificPackage} \n 💡 you can tell Pact where the npm package is located with env var $PACT_PREBUILD_PACKAGE_LOCATION`
Expand Down Expand Up @@ -93,14 +94,7 @@ const bindingsResolver = (bindingsPath: string | undefined) =>
bindings(bindingsPath);

const bindingPaths = [
path.resolve(
__dirname,
'..',
'..',
'node_modules',
getPlatformArchSpecificPackage()
),
path.resolve(__dirname, '..', '..'),
path.resolve(getPlatformArchSpecificPackage()),
process.env['PACT_PREBUILD_LOCATION']?.toString() ?? path.resolve(),
];
let ffiLib: Ffi;
Expand Down

0 comments on commit b6c0bf7

Please sign in to comment.