node-pty-package-assets.test.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. resolvePackagedNodePtyPrebuildPath,
  4. resolveSourceNodePtyPrebuildPath,
  5. } from "../scripts/node-pty-package-assets.mjs";
  6. describe("node-pty package assets", () => {
  7. it("resolves the unpacked node-pty prebuild path used by packaged Windows apps", () => {
  8. const resolvedPath = resolvePackagedNodePtyPrebuildPath({
  9. resourcesDir: "C:/Program Files/ZCode/resources",
  10. platformKey: "win32-x64",
  11. }).replaceAll("\\", "/");
  12. expect(resolvedPath).toContain("/resources/");
  13. expect(resolvedPath).toMatch(
  14. /app\.asar\.unpacked\/node_modules\/node-pty\/prebuilds\/win32-x64\/pty\.node$/,
  15. );
  16. });
  17. it("resolves linux source prebuilds through package exports compatible entrypoints", () => {
  18. for (const platformKey of ["linux-x64", "linux-arm64"]) {
  19. const resolvedPath = resolveSourceNodePtyPrebuildPath({
  20. sourcePackageName: `@lydell/node-pty-${platformKey}`,
  21. platformKey,
  22. }).replaceAll("\\", "/");
  23. expect(resolvedPath).toMatch(
  24. new RegExp(`@lydell/node-pty-${platformKey}/prebuilds/${platformKey}/pty\\.node$`),
  25. );
  26. }
  27. });
  28. it("resolves the unpacked node-pty prebuild path used by packaged Linux apps", () => {
  29. const resolvedPath = resolvePackagedNodePtyPrebuildPath({
  30. resourcesDir: "/opt/ZCode/resources",
  31. platformKey: "linux-x64",
  32. }).replaceAll("\\", "/");
  33. expect(resolvedPath).toContain("/opt/ZCode/resources/");
  34. expect(resolvedPath).toMatch(
  35. /app\.asar\.unpacked\/node_modules\/node-pty\/prebuilds\/linux-x64\/pty\.node$/,
  36. );
  37. });
  38. });