Allow a custom install path
crash7 opened this issue · 3 comments
Hello,
First of all, thanks for this lib and the serverless-dynamodb-local plugin!
I'm using this library through the serverless-dynamodb-local and when using it with yarn, I have to install the dynamodb jar everytime I install a new package (since yarn removes the bin folder that this lib creates to download the jar binary).
I have been able to make the changes that will use a better directory for this when using it with serverless (a .dynamodb dir int the service folder, same as .serverless one).
Most of the changes are in the serverless plugin, for this lib I just need to change the following piece of code in https://github.com/99xt/dynamodb-localhost/blob/master/dynamodb/starter.js
var starter = {
start: function (options, config) {
/* Dynamodb local documentation http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html */
var additionalArgs = [],
port = options.port || config.start.port,
- db_dir = utils.absPath(config.setup.install_path),
+ db_dir = options.install_path || utils.absPath(config.setup.install_path),
jar = config.setup.jar;
Then, in the serverless plugin I would change in https://github.com/99xt/serverless-dynamodb-local/blob/v1/index.js:
constructor(serverless, options) {
this.serverless = serverless;
this.service = serverless.service;
this.serverlessLog = serverless.cli.log.bind(serverless.cli);
this.config = this.service.custom && this.service.custom.dynamodb || {};
- this.options = options;
+ this.options = _.merge({
+ localPath: path.join(serverless.config.servicePath, '.dynamodb')
+ },
+ options
+ );
startHandler() {
const config = this.config;
const options = _.merge({
- sharedDb: this.options.sharedDb || true
+ sharedDb: this.options.sharedDb || true,
+ install_path: this.options.localPath
},
config && config.start,
this.options
);
// otherwise endHandler will be mis-informed
this.options = options;
if (!options.noStart) {
dynamodbLocal.start(options);
}
return BbPromise.resolve()
.then(() => options.migrate && this.migrateHandler())
.then(() => options.seed && this.seedHandler());
}
Let me know what you think! I have the changes ready so if you are ok, I can create the two PRs.
@rehrumesh @lakindu95 @mjzone Can you have a look at this?
+1
I'd love to see this get merged. Is there anything holding it up?