@@ -96,6 +96,13 @@ class ServerlessDynamodbLocal {
9696 }
9797 } ;
9898
99+ const stage = this . options . stage || this . service . provider . stage
100+ if ( this . config . stages && ! this . config . stages . includes ( stage ) ) {
101+ // don't do anything for this stage
102+ this . hooks = { }
103+ return
104+ }
105+
99106 this . hooks = {
100107 "dynamodb:migrate:migrateHandler" : this . migrateHandler . bind ( this ) ,
101108 "dynamodb:seed:seedHandler" : this . seedHandler . bind ( this ) ,
@@ -182,16 +189,9 @@ class ServerlessDynamodbLocal {
182189 this . options
183190 ) ;
184191
185- const stage = options . stage || this . serverless . service . provider . stage
186- let startThisStage = true ;
187- if ( options . stages && ! options . stages . includes ( stage ) ) {
188- startThisStage = false ;
189- }
190- options . startThisStage = startThisStage
191-
192192 // otherwise endHandler will be mis-informed
193193 this . options = options ;
194- if ( ! options . noStart && startThisStage ) {
194+ if ( ! options . noStart ) {
195195 dynamodbLocal . start ( options ) ;
196196 }
197197 return BbPromise . resolve ( )
@@ -200,7 +200,7 @@ class ServerlessDynamodbLocal {
200200 }
201201
202202 endHandler ( ) {
203- if ( ! this . options . noStart && this . options . startThisStage ) {
203+ if ( ! this . options . noStart ) {
204204 this . serverlessLog ( "DynamoDB - stopping local database" ) ;
205205 dynamodbLocal . stop ( this . port ) ;
206206 }
0 commit comments