Skip to content

Commit eea1f60

Browse files
Merge pull request #184 from mjzone/v1
Fixing dbPath not working with relative path issue #161
2 parents 4269776 + c8c0e20 commit eea1f60

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ServerlessDynamodbLocal {
1313
this.serverlessLog = serverless.cli.log.bind(serverless.cli);
1414
this.config = this.service.custom && this.service.custom.dynamodb || {};
1515
this.options = _.merge({
16-
localPath: path.join(serverless.config.servicePath, '.dynamodb')
16+
localPath: serverless.config && path.join(serverless.config.servicePath, '.dynamodb')
1717
},
1818
options
1919
);
@@ -105,7 +105,7 @@ class ServerlessDynamodbLocal {
105105
}
106106
};
107107

108-
const stage = this.options.stage || this.service.provider.stage;
108+
const stage = (this.options && this.options.stage) || (this.service.provider && this.service.provider.stage);
109109
if (this.config.stages && !this.config.stages.includes(stage)) {
110110
// don't do anything for this stage
111111
this.hooks = {};
@@ -206,6 +206,12 @@ class ServerlessDynamodbLocal {
206206

207207
// otherwise endHandler will be mis-informed
208208
this.options = options;
209+
210+
let dbPath = options.dbPath;
211+
if (dbPath) {
212+
options.dbPath = path.isAbsolute(dbPath) ? dbPath : path.join(this.serverless.config.servicePath, dbPath);
213+
}
214+
209215
if (!options.noStart) {
210216
dynamodbLocal.start(options);
211217
}

0 commit comments

Comments
 (0)