Skip to content

Commit

Permalink
fix: use instance.kill() in MemoryServer and update dependencies (#29)
Browse files Browse the repository at this point in the history
* 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 mime@2.0.3 incompatibility
Don't worry this library still works on Node v4. mime@2.0.3 is used by
semantic-release
  • Loading branch information
nodkz committed Nov 7, 2017
1 parent 5151f87 commit 8f3714d
Show file tree
Hide file tree
Showing 5 changed files with 497 additions and 582 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ cache:
notifications:
email: true
node_js:
- "7"
- "8"
- "6"
- "5"
- "4"
before_install: yarn global add greenkeeper-lockfile@1
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,39 @@
"homepage": "https://github.com/nodkz/mongodb-memory-server",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.0",
"babel-jest": "^21.0.2",
"babel-eslint": "^8.0.2",
"babel-jest": "^21.2.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.5.2",
"cz-conventional-changelog": "^2.0.0",
"eslint": "^4.6.1",
"eslint-config-airbnb-base": "^12.0.0",
"eslint-config-prettier": "^2.4.0",
"eslint-plugin-flowtype": "^2.35.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-prettier": "^2.1.1",
"flow-bin": "^0.54.1",
"jest": "^21.1.0",
"mongodb": "^2.2.28",
"babel-preset-env": "^1.6.1",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.10.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-config-prettier": "^2.7.0",
"eslint-plugin-flowtype": "^2.39.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-prettier": "^2.3.1",
"flow-bin": "^0.58.0",
"jest": "^21.2.1",
"mongodb": "^2.2.33",
"npm-run-all": "^4.1.1",
"prettier": "^1.6.1",
"prettier": "^1.8.0",
"rimraf": "^2.6.2",
"semantic-release": "^7.0.2"
"semantic-release": "^8.2.0"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"debug": "^3.0.1",
"debug": "^3.1.0",
"decompress": "^4.2.0",
"fs-extra": "^4.0.2",
"get-port": "^3.2.0",
"getos": "^3.0.1",
"getos": "^3.1.0",
"lockfile": "^1.0.3",
"md5-file": "^3.2.2",
"md5-file": "^3.2.3",
"mkdirp": "^0.5.1",
"request-promise": "^4.2.1",
"request-promise": "^4.2.2",
"tmp": "^0.0.33",
"uuid": "^3.0.1"
},
Expand Down
14 changes: 5 additions & 9 deletions src/MongoMemoryServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export default class MongoMemoryServer {
.catch(err => {
if (!this.opts.debug) {
throw new Error(
`${err.message}\n\nUse debug option for more info: new MongoMemoryServer({ debug: true })`
`${err.message}\n\nUse debug option for more info: ` +
`new MongoMemoryServer({ debug: true })`
);
}
throw err;
Expand Down Expand Up @@ -145,15 +146,10 @@ export default class MongoMemoryServer {
}

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

if (childProcess && childProcess.kill) {
this.debug(`Shutdown MongoDB server on port ${port} with pid ${childProcess.pid}`);
await new Promise(resolve => {
childProcess.once(`exit`, resolve);
childProcess.kill();
});
}
this.debug(`Shutdown MongoDB server on port ${port} with pid ${instance.getPid() || ''}`);
await instance.kill();

if (tmpDir) {
this.debug(`Removing tmpDir ${tmpDir.name}`);
Expand Down
4 changes: 2 additions & 2 deletions src/util/MongoBinaryDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ export default class MongoBinaryDownload {

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

Expand Down

0 comments on commit 8f3714d

Please sign in to comment.