Skip to content

Commit 7568c93

Browse files
don't fail if custom.dynamodb is undefined
As reported in #73, serverless-dynamodb-local fails if no config is defined in serverless.yml. This change makes the plugin fallback to default values if no configuration is provided. fixes #73
1 parent 42bf35e commit 7568c93

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class ServerlessDynamodbLocal {
99
constructor(serverless, options) {
1010
this.serverless = serverless;
1111
this.service = serverless.service;
12+
this.config = this.service.custom && this.service.custom.dynamodb || {};
1213
this.options = options;
1314
this.provider = 'aws';
1415
this.commands = {
@@ -86,8 +87,7 @@ class ServerlessDynamodbLocal {
8687

8788
dynamodbOptions() {
8889
let self = this;
89-
let config = self.service.custom.dynamodb || {},
90-
port = config.start && config.start.port || 8000,
90+
let port = self.config.start && self.config.start.port || 8000,
9191
dynamoOptions = {
9292
endpoint: 'http://localhost:' + port,
9393
region: 'localhost',
@@ -131,12 +131,11 @@ class ServerlessDynamodbLocal {
131131
startHandler() {
132132
let self = this;
133133
return new BbPromise(function (resolve) {
134-
let config = self.service.custom.dynamodb,
135-
options = _.merge({
134+
let options = _.merge({
136135
sharedDb: self.options.sharedDb || true
137136
},
138137
self.options,
139-
config && config.start
138+
self.config && self.config.start
140139
);
141140
if (options.migrate) {
142141
dynamodbLocal.start(options);
@@ -175,4 +174,4 @@ class ServerlessDynamodbLocal {
175174
});
176175
}
177176
}
178-
module.exports = ServerlessDynamodbLocal;
177+
module.exports = ServerlessDynamodbLocal;

0 commit comments

Comments
 (0)