Skip to content

Commit

Permalink
address pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
RichiCoder1 committed Jul 7, 2022
1 parent 72bc58b commit 914eb5f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/@aws-cdk/aws-synthetics/lib/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,16 @@ export class AssetCode extends Code {
* @param handler the canary handler
*/
private validateCanaryAsset(scope: Construct, handler: string, family: RuntimeFamily) {
if (!this.asset) {
throw new Error("'validateCanaryAsset' must be called after 'this.asset' is instantiated");
}

// Get the staged (or copied) asset path.
const assetOutdir = cdk.Stage.of(scope)?.assetOutdir;
let assetPath = this.assetPath;
if (assetOutdir) {
assetPath = path.join(assetOutdir, this.asset!.assetPath);
}
const assetPath = assetOutdir ? path.join(assetOutdir, this.asset.assetPath) : this.assetPath;

if (path.extname(this.assetPath) !== '.zip') {
if (this.asset!.isFile) {
if (this.asset.isFile) {
throw new Error(`Asset must be a .zip file or a directory (${this.assetPath})`);
}
const filename = handler.split('.')[0];
Expand Down

0 comments on commit 914eb5f

Please sign in to comment.