Skip to content

Commit 3edcbf4

Browse files
Merge pull request #114 from RedbirdHQ/v1
Adding a `noStart` option
2 parents aea6366 + 25103d3 commit 3edcbf4

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ custom:
6565
inMemory: true
6666
migrate: true
6767
seed: true
68+
# Uncomment only if you already have a DynamoDB running locally
69+
# noStart: true
6870
```
6971

7072
## Migrations: sls dynamodb migrate

index.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ class ServerlessDynamodbLocal {
6666
}
6767
}
6868
},
69+
noStart: {
70+
shortcut: "n",
71+
default: false,
72+
usage: "Do not start DynamoDB local (in case it is already running)",
73+
},
6974
remove: {
7075
lifecycleEvents: ["removeHandler"],
7176
usage: "Removes local DynamoDB"
@@ -144,23 +149,27 @@ class ServerlessDynamodbLocal {
144149
}
145150

146151
startHandler() {
147-
const config = this.config;
148-
const options = _.merge({
149-
sharedDb: this.options.sharedDb || true
150-
},
151-
config && config.start,
152-
this.options
153-
);
154-
155-
dynamodbLocal.start(options);
152+
if (!this.options.noStart) {
153+
const config = this.config;
154+
const options = _.merge({
155+
sharedDb: this.options.sharedDb || true
156+
},
157+
config && config.start,
158+
this.options
159+
);
160+
161+
dynamodbLocal.start(options);
162+
}
156163
return BbPromise.resolve()
157164
.then(() => options.migrate && this.migrateHandler())
158165
.then(() => options.seed && this.seedHandler());
159166
}
160167

161168
endHandler() {
162-
this.serverlessLog('DynamoDB - stopping local database');
163-
dynamodbLocal.stop(this.port);
169+
if (!this.options.noStart) {
170+
this.serverlessLog("DynamoDB - stopping local database");
171+
dynamodbLocal.stop(this.port);
172+
}
164173
}
165174

166175
/**

package.json

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-dynamodb-local",
3-
"version": "0.2.22",
3+
"version": "0.2.23",
44
"engines": {
55
"node": ">=4.0"
66
},
@@ -12,20 +12,20 @@
1212
"url": "https://github.com/99xt/serverless-dynamodb-local"
1313
},
1414
"keywords": [
15-
"serverless framework plugin",
16-
"serverless applications",
17-
"serverless plugins",
18-
"api gateway",
19-
"lambda",
20-
"dynamodb",
21-
"dynamodb local",
22-
"aws",
23-
"aws lambda",
24-
"aws dynamodb",
25-
"amazon",
26-
"amazon web services",
27-
"serverless.com"
28-
],
15+
"serverless framework plugin",
16+
"serverless applications",
17+
"serverless plugins",
18+
"api gateway",
19+
"lambda",
20+
"dynamodb",
21+
"dynamodb local",
22+
"aws",
23+
"aws lambda",
24+
"aws dynamodb",
25+
"amazon",
26+
"amazon web services",
27+
"serverless.com"
28+
],
2929
"main": "index.js",
3030
"bin": {},
3131
"scripts": {
@@ -36,5 +36,10 @@
3636
"bluebird": "^3.4.6",
3737
"dynamodb-localhost": "^0.0.5",
3838
"lodash": "^4.17.0"
39+
},
40+
"devDependencies": {
41+
"chai": "^4.1.1",
42+
"mocha": "^3.5.0",
43+
"should": "^11.2.1"
3944
}
4045
}

test/indexTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("Port function",function(){
1515
});
1616

1717
it("Port value should be >= 0 and < 65536",function () {
18-
http.get(dataApp.prototype.port, function (response) {
18+
http.get(`http://localhost:${dataApp.prototype.port}`, function (response) {
1919
assert.equal(response.statusCode, 200);
2020
});
2121
});

0 commit comments

Comments
 (0)