Skip to content

Don't ignore --port and --host CLI options for migrations after start #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -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;
}

/**
30 changes: 30 additions & 0 deletions test/cliTest.js
Original file line number Diff line number Diff line change
@@ -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");
});
});
});