mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
lambda reported any ERR_MODULE_NOT_FOUND as '@hyperframes/aws-lambda is not installed', and cloudrun matched its package name anywhere in the message, which also names the adapter when one of its own dependencies is missing. Both now use one helper that matches only Node's "Cannot find package '<pkg>'" and rethrow anything else.
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { isMissingPackageError, missingPackageMessage } from "./missingPackage.js";
|
|
|
|
const notFound = (message: string) =>
|
|
Object.assign(new Error(message), { code: "ERR_MODULE_NOT_FOUND" });
|
|
|
|
describe("isMissingPackageError", () => {
|
|
it("is true when the package itself is absent", () => {
|
|
const err = notFound("Cannot find package '@hyperframes/aws-lambda' imported from /app/cli.js");
|
|
expect(isMissingPackageError(err, "@hyperframes/aws-lambda")).toBe(true);
|
|
});
|
|
|
|
it("is false when an installed package is missing one of its own dependencies", () => {
|
|
const err = notFound(
|
|
"Cannot find package 'google-auth-library' imported from /app/node_modules/@hyperframes/gcp-cloud-run/dist/sdk.js",
|
|
);
|
|
expect(isMissingPackageError(err, "@hyperframes/gcp-cloud-run")).toBe(false);
|
|
});
|
|
|
|
it("is false for other error codes", () => {
|
|
const err = Object.assign(new Error("Cannot find package '@hyperframes/aws-lambda'"), {
|
|
code: "ERR_UNKNOWN_FILE_EXTENSION",
|
|
});
|
|
expect(isMissingPackageError(err, "@hyperframes/aws-lambda")).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("missingPackageMessage", () => {
|
|
it("names the command and both install commands", () => {
|
|
const message = missingPackageMessage("@hyperframes/aws-lambda", "hyperframes lambda deploy");
|
|
expect(message).toContain("hyperframes lambda deploy");
|
|
expect(message).toContain("npm install -g @hyperframes/aws-lambda");
|
|
expect(message).toContain("npm install @hyperframes/aws-lambda");
|
|
});
|
|
});
|