Skip to content

Commit d13e2d3

Browse files
committed
Don't ignore --port and --host CLI options for migrations after start
1 parent 07e3edc commit d13e2d3

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

index.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class ServerlessDynamodbLocal {
4343
shortcut: "p",
4444
usage: "The port number that DynamoDB will use to communicate with your application. If you do not specify this option, the default port is 8000"
4545
},
46+
host: {
47+
shortcut: "h",
48+
usage: "The host name that DynamoDB will use to communicate with your application. If you do not specify this option, the default host name is 'localhost'"
49+
},
4650
cors: {
4751
shortcut: "c",
4852
usage: "Enable CORS support (cross-origin resource sharing) for JavaScript. You must provide a comma-separated \"allow\" list of specific domains. The default setting for -cors is an asterisk (*), which allows public access."
@@ -127,15 +131,25 @@ class ServerlessDynamodbLocal {
127131
}
128132

129133
get port() {
130-
const config = this.service.custom && this.service.custom.dynamodb || {};
131-
const port = _.get(config, "start.port", 8000);
132-
return port;
134+
const config = this.service.custom && this.service.custom.dynamodb || {};
135+
const options = _.merge(
136+
{},
137+
config.start,
138+
this.options
139+
);
140+
const port = options["port"] || 8000;
141+
return port;
133142
}
134143

135144
get host() {
136-
const config = this.service.custom && this.service.custom.dynamodb || {};
137-
const host = _.get(config, "start.host", "localhost");
138-
return host;
145+
const config = this.service.custom && this.service.custom.dynamodb || {};
146+
const options = _.merge(
147+
{},
148+
config.start,
149+
this.options
150+
);
151+
const host = options["host"] || "localhost";
152+
return host;
139153
}
140154

141155
/**

test/cliTest.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"use strict";
2+
//Define the modules required to mocha testing
3+
const assert = require("chai").assert;
4+
const http = require ("http");
5+
const expect = require("chai").expect;
6+
const should = require("should");
7+
const aws = require ("aws-sdk");
8+
const seeder = require("../src/seeder.js");
9+
const Plugin = require("../index.js");
10+
11+
const serverlessMock = require("./serverlessMock");
12+
13+
describe("command line options",function(){
14+
describe("for 'start' command",function(){
15+
let service;
16+
before(function(){
17+
this.timeout(60000);
18+
service = new Plugin(serverlessMock, { port: 8123, host: "home.local" });
19+
//return service.startHandler();
20+
});
21+
22+
it(".port should return cli option",function(){
23+
assert.equal(service.port, 8123);
24+
});
25+
26+
it(".host should return cli option",function(){
27+
assert.equal(service.host, "home.local");
28+
});
29+
});
30+
});

0 commit comments

Comments
 (0)