Skip to content

Commit

Permalink
fix(aws-lambda): code.asset now supports jar files, fixes #1294 (#1330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Witbeck authored and Elad Ben-Israel committed Dec 12, 2018
1 parent c4a9b74 commit 3076070
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/@aws-cdk/assets/lib/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Binary file not shown.
5 changes: 5 additions & 0 deletions packages/@aws-cdk/assets/test/test.asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

0 comments on commit 3076070

Please sign in to comment.