Skip to content

🎥 Make videos programmatically with React

get it started

Jonny Burgerdb8bebfe49d7
diff --git a/packages/docs/docs/lambda/deploysite.md b/packages/docs/docs/lambda/deploysite.mdx
similarity index 96%
rename from packages/docs/docs/lambda/deploysite.md
rename to packages/docs/docs/lambda/deploysite.mdx
index dcd7aa7d2d..266a0a72e4 100644
--- a/packages/docs/docs/lambda/deploysite.md
+++ b/packages/docs/docs/lambda/deploysite.mdx
@@ -69,7 +69,8 @@ Specify the subfolder in your S3 bucket that you want the site to deploy to. If
### `logLevel?`<AvailableFrom v="4.0.140"/>
_optional_
-<Options id="log"/>
+
+<Options id="log" />
### `options?`
@@ -126,6 +127,11 @@ _available from v3.3.97_
Either `public` (default) or `no-acl` if you are not using ACL. Sites must have a public URL to be able to be rendered on Lambda, since the headless browser opens that URL.
+### `throwIfSiteExists`<AvailableFrom v="4.0.141"/>
+
+Prevents accidential update of an existing site.
+If there are any files in the subfolder where the site should be placed, this function will throw.
+
## Return value
An object with the following values:
diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.ts
index 726dc58e10..a989b94974 100644
--- a/packages/lambda/src/api/deploy-site.ts
+++ b/packages/lambda/src/api/deploy-site.ts
@@ -36,6 +36,7 @@ export type DeploySiteInput = {
privacy?: 'public' | 'no-acl';
gitSource?: GitSource | null;
logLevel?: LogLevel;
+ throwIfSiteExists?: boolean;
};
export type DeploySiteOutput = Promise<{
@@ -56,6 +57,7 @@ const internalDeploySite = async ({
region,
privacy: passedPrivacy,
gitSource,
+ throwIfSiteExists,
}: DeploySiteInput & {
logLevel: LogLevel;
indent: boolean;
@@ -104,6 +106,16 @@ const internalDeploySite = async ({
}),
]);
+ if (throwIfSiteExists && files.length > 0) {
+ throw new Error(
+ '`throwIfSiteExists` was passed as true, but there are already files in this folder: ' +
+ files
+ .slice(0, 5)
+ .map((f) => f.Key)
+ .join(', '),
+ );
+ }
+
const {toDelete, toUpload, existingCount} = await getS3DiffOperations({
objects: files,
bundle: bundled,