From 3076070e253b59531466dc9d32a89537d63a1638 Mon Sep 17 00:00:00 2001 From: Shane Witbeck Date: Tue, 11 Dec 2018 23:19:27 -0800 Subject: [PATCH] fix(aws-lambda): code.asset now supports jar files, fixes #1294 (#1330) --- packages/@aws-cdk/assets/lib/asset.ts | 3 ++- .../sample-asset-directory/sample-jar-asset.jar | Bin 0 -> 211 bytes packages/@aws-cdk/assets/test/test.asset.ts | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk/assets/test/sample-asset-directory/sample-jar-asset.jar diff --git a/packages/@aws-cdk/assets/lib/asset.ts b/packages/@aws-cdk/assets/lib/asset.ts index ba26f3a737269..a075ef5829be0 100644 --- a/packages/@aws-cdk/assets/lib/asset.ts +++ b/packages/@aws-cdk/assets/lib/asset.ts @@ -88,9 +88,10 @@ export class Asset extends cdk.Construct { this.assetPath = path.resolve(props.path); // sets isZipArchive based on the type of packaging and file extension + const allowedExtensions: string[] = ['.jar', '.zip']; this.isZipArchive = props.packaging === AssetPackaging.ZipDirectory ? true - : this.assetPath.toLowerCase().endsWith('.zip'); + : allowedExtensions.some(ext => this.assetPath.toLowerCase().endsWith(ext)); validateAssetOnDisk(this.assetPath, props.packaging); diff --git a/packages/@aws-cdk/assets/test/sample-asset-directory/sample-jar-asset.jar b/packages/@aws-cdk/assets/test/sample-asset-directory/sample-jar-asset.jar new file mode 100644 index 0000000000000000000000000000000000000000..71224bd574e4b201374ee5f7d55ce7f0e523cd9b GIT binary patch literal 211 zcmWIWW@h1H0D&}CQ(sOuvsPgs8-zs}WEhGQa|?1(brXw=Q%iKyGILV(N-9c1LpT|j z3q+Pgw+9`IF0J5ZU}VwW)T_aArkc4>Utb|3H76%uAtg1jNCB)bz?+dtjv1F75+JJ? h7=d_6BZ!5=MplT8Xto7-v$BCSF#=&UkWK<|7ytsvE`0z1 literal 0 HcmV?d00001 diff --git a/packages/@aws-cdk/assets/test/test.asset.ts b/packages/@aws-cdk/assets/test/test.asset.ts index fbfc4cad4a209..c7395deac8634 100644 --- a/packages/@aws-cdk/assets/test/test.asset.ts +++ b/packages/@aws-cdk/assets/test/test.asset.ts @@ -130,10 +130,15 @@ export = { path: path.join(__dirname, 'sample-asset-directory', 'sample-zip-asset.zip') }); + const jarFileAsset = new FileAsset(stack, 'JarFileAsset', { + path: path.join(__dirname, 'sample-asset-directory', 'sample-jar-asset.jar') + }); + // THEN test.equal(nonZipAsset.isZipArchive, false); test.equal(zipDirectoryAsset.isZipArchive, true); test.equal(zipFileAsset.isZipArchive, true); + test.equal(jarFileAsset.isZipArchive, true); test.done(); } };