lambda-live-debugger
Version:
Debug Lambda functions locally like it is running in the cloud
15 lines (14 loc) • 669 B
JavaScript
import { getSanitizedTypeScriptVersion } from "./getSanitizedTypeScriptVersion";
const ALLOWED_PREFIXES = ["^", "~", ">=", "<=", ">", "<"];
const ALLOWED_DIST_TAGS = ["latest", "beta", "dev", "rc", "insiders", "next"];
export const getSanitizedDevTypeScriptVersion = (version = "") => {
if (ALLOWED_DIST_TAGS.includes(version)) {
return version;
}
const prefix = ALLOWED_PREFIXES.find((p) => version.startsWith(p)) ?? "";
const sanitizedTypeScriptVersion = getSanitizedTypeScriptVersion(version.slice(prefix.length));
if (!sanitizedTypeScriptVersion) {
return undefined;
}
return `${prefix}${sanitizedTypeScriptVersion}`;
};