diff --git a/index.js b/index.js index c0fb955c..f52493cc 100644 --- a/index.js +++ b/index.js @@ -43,6 +43,10 @@ class ServerlessDynamodbLocal { shortcut: "p", 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" }, + host: { + shortcut: "h", + 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'" + }, cors: { shortcut: "c", 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 { } get port() { - const config = this.service.custom && this.service.custom.dynamodb || {}; - const port = _.get(config, "start.port", 8000); - return port; + const config = this.service.custom && this.service.custom.dynamodb || {}; + const options = _.merge( + {}, + config.start, + this.options + ); + const port = options["port"] || 8000; + return port; } get host() { - const config = this.service.custom && this.service.custom.dynamodb || {}; - const host = _.get(config, "start.host", "localhost"); - return host; + const config = this.service.custom && this.service.custom.dynamodb || {}; + const options = _.merge( + {}, + config.start, + this.options + ); + const host = options["host"] || "localhost"; + return host; } /** diff --git a/test/cliTest.js b/test/cliTest.js new file mode 100644 index 00000000..0cf6a65e --- /dev/null +++ b/test/cliTest.js @@ -0,0 +1,30 @@ +"use strict"; +//Define the modules required to mocha testing +const assert = require("chai").assert; +const http = require ("http"); +const expect = require("chai").expect; +const should = require("should"); +const aws = require ("aws-sdk"); +const seeder = require("../src/seeder.js"); +const Plugin = require("../index.js"); + +const serverlessMock = require("./serverlessMock"); + +describe("command line options",function(){ + describe("for 'start' command",function(){ + let service; + before(function(){ + this.timeout(60000); + service = new Plugin(serverlessMock, { port: 8123, host: "home.local" }); + //return service.startHandler(); + }); + + it(".port should return cli option",function(){ + assert.equal(service.port, 8123); + }); + + it(".host should return cli option",function(){ + assert.equal(service.host, 'home.local'); + }); + }); +}); \ No newline at end of file