Skip to content

Commit

Permalink
Skip static file deployment if no files
Browse files Browse the repository at this point in the history
  • Loading branch information
revmischa committed Nov 8, 2022
1 parent 958241d commit a75d28d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/NextjsAssetsDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class NextJsAssetsDeployment extends Construct {
compressionLevel: this.props.compressionLevel,
quiet: this.props.quiet,
});
if (!archiveZipFilePath) return [];

const deployment = new BucketDeployment(this, 'NextStaticAssetsS3Deployment', {
destinationBucket: this.bucket,
Expand Down
5 changes: 4 additions & 1 deletion src/NextjsBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ export function createArchive({
fileGlob = '*',
compressionLevel = 1,
quiet,
}: CreateArchiveArgs): string {
}: CreateArchiveArgs): string | null {
// if directory is empty, can skip
if (!fs.existsSync(directory) || fs.readdirSync(directory).length === 0) return null;

zipOutDir = path.resolve(zipOutDir);
fs.mkdirpSync(zipOutDir);
// get output path
Expand Down
1 change: 1 addition & 0 deletions src/NextjsLambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class NextJsLambda extends Construct {
fileGlob: '*',
quiet: props.quiet,
});
if (!zipFilePath) throw new Error('Failed to create archive for lambda function code');

// build native deps layer
const nextLayer = new NextjsLayer(scope, 'NextjsLayer', {});
Expand Down

0 comments on commit a75d28d

Please sign in to comment.