only add the al2023 stuff on node 20

This commit is contained in:
Sparticuz 2023-11-16 12:33:04 -05:00
parent b6817b6bac
commit 28b086cee9
4 changed files with 17 additions and 1 deletions

BIN
bin/al.2023.tar.br Normal file

Binary file not shown.

Binary file not shown.

View File

@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
import { extract } from "tar-fs";
import { parse } from "node:url";
import type { UrlWithStringQuery } from "node:url";
import { version } from "node:process";
interface FollowRedirOptions extends UrlWithStringQuery {
maxBodyLength: number;
@ -38,6 +39,13 @@ export const isRunningInAwsLambda = () => {
return false;
};
export const isRunningInAwsLambdaNode20 = () => {
if (version.startsWith("v20")) {
return true;
}
return false;
};
export const downloadAndExtract = async (url: string) =>
new Promise<string>((resolve, reject) => {
const getOptions = parse(url) as FollowRedirOptions;

View File

@ -9,7 +9,12 @@ import { https } from "follow-redirects";
import LambdaFS from "./lambdafs";
import { join } from "node:path";
import { URL } from "node:url";
import { downloadAndExtract, isRunningInAwsLambda, isValidUrl } from "./helper";
import {
downloadAndExtract,
isRunningInAwsLambda,
isValidUrl,
isRunningInAwsLambdaNode20,
} from "./helper";
/** Viewport taken from https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.viewport.md */
interface Viewport {
@ -308,6 +313,9 @@ class Chromium {
if (isRunningInAwsLambda()) {
// If running in AWS Lambda, extract more required files
promises.push(LambdaFS.inflate(`${input}/aws.tar.br`));
if (isRunningInAwsLambdaNode20()) {
promises.push(LambdaFS.inflate(`${input}/al.2023.tar.br`));
}
}
// Await all extractions