fix: Skip invocation of hooks and unzip / delete commands if no hooks are registered #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for creating this construct - it makes working with .NET Lambda functions in CDK a much better experience!
Out of curiosity I have been reading through the code base to learn more about how this construct has been implemented, and I noticed a minor optimization that can be done.
The construct was already (implicitly) using
AUTO_DISCOVERas bundling output type, which according to the docs means:This also means that if no hooks are registered, then there is a such no need to go through the work of unzipping the produced
package.zipfile, just for the CDK to zip it again.This PR introduces a simple check, to see if hooks are registered, and if not, the produced command is simply just the
dotnetPackageCommandwhich spits out apackage.zip, which, due to the use ofAUTO_DISCOVERas bundling output type, is then picked up and use as code asset by the CDK.On top of this, while the bundling output type in CDK does default to
AUTO_DISCOVER, I have now configured it in code, just to make it explicit that the this "auto mode" is in fact used as part of the construct's logic.