@ff-labs%2Ffff-bun@0.9.3.patch 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. diff --git a/src/download.ts b/src/download.ts
  2. index 3454256..6dca25a 100644
  3. --- a/src/download.ts
  4. +++ b/src/download.ts
  5. @@ -7,7 +7,7 @@
  6. */
  7. +declare const FFF_LIBC: "gnu" | "musl";
  8. import { existsSync } from "node:fs";
  9. -import { createRequire } from "node:module";
  10. import { dirname, join } from "node:path";
  11. import { fileURLToPath } from "node:url";
  12. import { getLibFilename, getNpmPackageName } from "./platform";
  13. @@ -54,14 +54,10 @@ export function binaryExists(): boolean {
  14. * in the same directory.
  15. */
  16. function resolveFromNpmPackage(): string | null {
  17. - const packageName = getNpmPackageName();
  18. -
  19. try {
  20. - // Use createRequire to resolve the platform package's location
  21. - const require = createRequire(join(getPackageDir(), "package.json"));
  22. - const packageJsonPath = require.resolve(`${packageName}/package.json`);
  23. - const packageDir = dirname(packageJsonPath);
  24. - const binaryPath = join(packageDir, getLibFilename());
  25. + const binaryPath = require(
  26. + `@ff-labs/fff-bin-${process.platform === "linux" ? `linux-${process.arch}-${typeof FFF_LIBC === "string" ? FFF_LIBC : getNpmPackageName().endsWith("musl") ? "musl" : "gnu"}` : `${process.platform}-${process.arch}`}/${process.platform === "win32" ? "fff_c.dll" : process.platform === "darwin" ? "libfff_c.dylib" : "libfff_c.so"}`,
  27. + );
  28. if (existsSync(binaryPath)) {
  29. return binaryPath;