Skip to content

🎥 Make videos programmatically with React

fix ci

Jonny Burger2c367ca42dd0
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index 6f50b3c793..063447f1c1 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -208,6 +208,7 @@ export const Internals = {
invalidCompositionErrorMessage,
isCompositionIdValid,
DEFAULT_OVERWRITE,
+ isInLambda: () => Boolean(process?.env?.LAMBDA_TASK_ROOT),
};
export type {
diff --git a/packages/lambda/src/cli/get-aws-region.ts b/packages/lambda/src/cli/get-aws-region.ts
index 22badb6b8a..85f6275ffc 100644
--- a/packages/lambda/src/cli/get-aws-region.ts
+++ b/packages/lambda/src/cli/get-aws-region.ts
@@ -1,11 +1,11 @@
+import {Internals} from 'remotion';
import {AwsRegion} from '../pricing/aws-regions';
import {DEFAULT_REGION} from '../shared/constants';
-import {isInLambda} from '../shared/is-in-lambda';
import {validateAwsRegion} from '../shared/validate-aws-region';
import {parsedLambdaCli} from './args';
export const getAwsRegion = (): AwsRegion => {
- if (isInLambda) {
+ if (Internals.isInLambda()) {
throw new Error('Should not call getAwsRegion() if in lambda');
}
diff --git a/packages/lambda/src/functions/helpers/get-current-region.ts b/packages/lambda/src/functions/helpers/get-current-region.ts
index b97342c59c..15bf55da1f 100644
--- a/packages/lambda/src/functions/helpers/get-current-region.ts
+++ b/packages/lambda/src/functions/helpers/get-current-region.ts
@@ -1,8 +1,8 @@
+import {Internals} from 'remotion';
import {AwsRegion} from '../../pricing/aws-regions';
-import {isInLambda} from '../../shared/is-in-lambda';
export const getCurrentRegionInFunction = () => {
- if (!isInLambda) {
+ if (!Internals.isInLambda()) {
throw new Error(
'Should not call getCurrentRegion() if not inside a lambda function'
);
diff --git a/packages/lambda/src/functions/helpers/uniq-by.ts b/packages/lambda/src/functions/helpers/uniq-by.ts
deleted file mode 100644
index 3b4f49f189..0000000000
--- a/packages/lambda/src/functions/helpers/uniq-by.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-export const uniqBy = <T>(arr: T[], predicate: (item: T) => string) => {
- const result: T[] = [];
- const map = new Map();
-
- arr.forEach((item) => {
- const key = item === null || item === undefined ? item : predicate(item);
-
- if (!map.has(key)) {
- map.set(key, item);
- result.push(item);
- }
- });
-
- return result;
-};
diff --git a/packages/lambda/src/shared/is-in-lambda.ts b/packages/lambda/src/shared/is-in-lambda.ts
deleted file mode 100644
index 5d5ed345da..0000000000
--- a/packages/lambda/src/shared/is-in-lambda.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export const isInLambda =
- Boolean(process.env.LAMBDA_TASK_ROOT) ||
- process.env.JEST_WORKER_ID !== undefined;
diff --git a/packages/lambda/src/test/price-calculation.test.ts b/packages/lambda/src/test/price-calculation.test.ts
index 4273d69aa0..682f5e04ff 100644
--- a/packages/lambda/src/test/price-calculation.test.ts
+++ b/packages/lambda/src/test/price-calculation.test.ts
@@ -2,6 +2,7 @@ import {estimatePriceFromBucket} from '../functions/helpers/calculate-price-from
test('Should not throw while calculating prices when time shifts occur', () => {
const aDate = Date.now();
+ process.env.LAMBDA_TASK_ROOT = 'true';
process.env.AWS_REGION = 'us-east-1';
const price = estimatePriceFromBucket({
diff --git a/packages/renderer/src/tmp-dir.ts b/packages/renderer/src/tmp-dir.ts
index 811a3b5eb3..b31f82f06e 100644
--- a/packages/renderer/src/tmp-dir.ts
+++ b/packages/renderer/src/tmp-dir.ts
@@ -1,6 +1,7 @@
import {mkdirSync} from 'fs';
import os from 'os';
import path from 'path';
+import {Internals} from 'remotion';
const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';
@@ -13,10 +14,8 @@ const randomHash = (): string => {
.join('');
};
-const isInLambda = Boolean(process.env.LAMBDA_TASK_ROOT);
-
export const tmpDir = (str: string) => {
- if (isInLambda) {
+ if (Internals.isInLambda()) {
const dir = '/tmp/' + str + randomHash();
mkdirSync(dir);
return dir;