@@ -96,6 +96,13 @@ class ServerlessDynamodbLocal {
96
96
}
97
97
} ;
98
98
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
+
99
106
this . hooks = {
100
107
"dynamodb:migrate:migrateHandler" : this . migrateHandler . bind ( this ) ,
101
108
"dynamodb:seed:seedHandler" : this . seedHandler . bind ( this ) ,
@@ -182,16 +189,9 @@ class ServerlessDynamodbLocal {
182
189
this . options
183
190
) ;
184
191
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
-
192
192
// otherwise endHandler will be mis-informed
193
193
this . options = options ;
194
- if ( ! options . noStart && startThisStage ) {
194
+ if ( ! options . noStart ) {
195
195
dynamodbLocal . start ( options ) ;
196
196
}
197
197
return BbPromise . resolve ( )
@@ -200,7 +200,7 @@ class ServerlessDynamodbLocal {
200
200
}
201
201
202
202
endHandler ( ) {
203
- if ( ! this . options . noStart && this . options . startThisStage ) {
203
+ if ( ! this . options . noStart ) {
204
204
this . serverlessLog ( "DynamoDB - stopping local database" ) ;
205
205
dynamodbLocal . stop ( this . port ) ;
206
206
}
0 commit comments