Skip to content

Commit 8f3714d

Browse files
authored
fix: use instance.kill() in MemoryServer and update dependencies (#29)
* fix(MemoryServer): use instance.kill() instead of childProcess.kill() * build(CI): test on Node versions 8, 6, 4 * chore(package): update dpendencies and fix new prettier errors * build(ci): remove tests on node 4 due [email protected] incompatibility Don't worry this library still works on Node v4. [email protected] is used by semantic-release
1 parent 5151f87 commit 8f3714d

File tree

5 files changed

+497
-582
lines changed

5 files changed

+497
-582
lines changed

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ cache:
88
notifications:
99
email: true
1010
node_js:
11-
- "7"
11+
- "8"
1212
- "6"
13-
- "5"
14-
- "4"
1513
before_install: yarn global add greenkeeper-lockfile@1
1614
before_script: greenkeeper-lockfile-update
1715
after_script: greenkeeper-lockfile-upload

package.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,39 @@
2424
"homepage": "https://github.com/nodkz/mongodb-memory-server",
2525
"devDependencies": {
2626
"babel-cli": "^6.26.0",
27-
"babel-eslint": "^8.0.0",
28-
"babel-jest": "^21.0.2",
27+
"babel-eslint": "^8.0.2",
28+
"babel-jest": "^21.2.0",
2929
"babel-plugin-transform-class-properties": "^6.24.1",
3030
"babel-plugin-transform-flow-strip-types": "^6.22.0",
3131
"babel-plugin-transform-object-rest-spread": "^6.26.0",
3232
"babel-plugin-transform-runtime": "^6.23.0",
33-
"babel-preset-env": "^1.5.2",
34-
"cz-conventional-changelog": "^2.0.0",
35-
"eslint": "^4.6.1",
36-
"eslint-config-airbnb-base": "^12.0.0",
37-
"eslint-config-prettier": "^2.4.0",
38-
"eslint-plugin-flowtype": "^2.35.1",
39-
"eslint-plugin-import": "^2.3.0",
40-
"eslint-plugin-prettier": "^2.1.1",
41-
"flow-bin": "^0.54.1",
42-
"jest": "^21.1.0",
43-
"mongodb": "^2.2.28",
33+
"babel-preset-env": "^1.6.1",
34+
"cz-conventional-changelog": "^2.1.0",
35+
"eslint": "^4.10.0",
36+
"eslint-config-airbnb-base": "^12.1.0",
37+
"eslint-config-prettier": "^2.7.0",
38+
"eslint-plugin-flowtype": "^2.39.1",
39+
"eslint-plugin-import": "^2.8.0",
40+
"eslint-plugin-prettier": "^2.3.1",
41+
"flow-bin": "^0.58.0",
42+
"jest": "^21.2.1",
43+
"mongodb": "^2.2.33",
4444
"npm-run-all": "^4.1.1",
45-
"prettier": "^1.6.1",
45+
"prettier": "^1.8.0",
4646
"rimraf": "^2.6.2",
47-
"semantic-release": "^7.0.2"
47+
"semantic-release": "^8.2.0"
4848
},
4949
"dependencies": {
5050
"babel-runtime": "^6.26.0",
51-
"debug": "^3.0.1",
51+
"debug": "^3.1.0",
5252
"decompress": "^4.2.0",
5353
"fs-extra": "^4.0.2",
5454
"get-port": "^3.2.0",
55-
"getos": "^3.0.1",
55+
"getos": "^3.1.0",
5656
"lockfile": "^1.0.3",
57-
"md5-file": "^3.2.2",
57+
"md5-file": "^3.2.3",
5858
"mkdirp": "^0.5.1",
59-
"request-promise": "^4.2.1",
59+
"request-promise": "^4.2.2",
6060
"tmp": "^0.0.33",
6161
"uuid": "^3.0.1"
6262
},

src/MongoMemoryServer.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ export default class MongoMemoryServer {
9595
.catch(err => {
9696
if (!this.opts.debug) {
9797
throw new Error(
98-
`${err.message}\n\nUse debug option for more info: new MongoMemoryServer({ debug: true })`
98+
`${err.message}\n\nUse debug option for more info: ` +
99+
`new MongoMemoryServer({ debug: true })`
99100
);
100101
}
101102
throw err;
@@ -145,15 +146,10 @@ export default class MongoMemoryServer {
145146
}
146147

147148
async stop(): Promise<boolean> {
148-
const { childProcess, port, tmpDir } = (await this.getInstanceData(): MongoInstanceDataT);
149+
const { instance, port, tmpDir } = (await this.getInstanceData(): MongoInstanceDataT);
149150

150-
if (childProcess && childProcess.kill) {
151-
this.debug(`Shutdown MongoDB server on port ${port} with pid ${childProcess.pid}`);
152-
await new Promise(resolve => {
153-
childProcess.once(`exit`, resolve);
154-
childProcess.kill();
155-
});
156-
}
151+
this.debug(`Shutdown MongoDB server on port ${port} with pid ${instance.getPid() || ''}`);
152+
await instance.kill();
157153

158154
if (tmpDir) {
159155
this.debug(`Removing tmpDir ${tmpDir.name}`);

src/util/MongoBinaryDownload.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ export default class MongoBinaryDownload {
190190

191191
const crReturn = this.platform === 'win32' ? '\x1b[0G' : '\r';
192192
process.stdout.write(
193-
`Downloading MongoDB ${this.version}: ${percentComplete} % (${mbComplete}mb / ${this
194-
.dlProgress.totalMb}mb)${crReturn}`
193+
`Downloading MongoDB ${this.version}: ${percentComplete} % (${mbComplete}mb ` +
194+
`/ ${this.dlProgress.totalMb}mb)${crReturn}`
195195
);
196196
}
197197

0 commit comments

Comments
 (0)