Properly supporting sls deploy function
command and zip option
#217
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.
This PR fixes two issues I encountered while using
individually: true
option.1. Should package only the given function when invoked by
sls deploy function --function $FN_NAME
Suppose using
individually: true
. If you'd like to deploy a single function usingsls deploy function
command you'd expect the plugin to package only the module that contains the function specified. The current implementation, however, runs packaging for every module inserverless.yml
definition, taking as much time as deploying all applications just to deploy a single function.I simply added explicit
targetFuncs
property to filter target function if any specified in command line option.2.
moveModulesUp
should be called regardless ofzip
optionWhen
individually: true
, each deployed function has its module as a root directory. This is achieved by callingmoveModulesUp
, but this method call is ignored whenzip
option is enabled. This certainly seems to be a wrong implementation (causing #203). IfinjectModule
is ensured not to be called whenzip: true
, it is safe to callmoveModulesUp
whetherzip
is enabled or not.The fix seems to work well on my case, but it lacks new unit tests (I couldn't figure out how to compose one.) If you let me known how to add a test, I'll update the PR as soon as I can.