Skip to content

Commit 88119d4

Browse files
committed
style(README): add note about what package.json is used
- add an additional note about what package.json is used by default - add example on how to change the package.json used
1 parent 22d765d commit 88119d4

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

README.md

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,34 @@ Works perfectly [with Travis CI](https://github.com/nodkz/graphql-compose-mongoo
2525
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
2626
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
2727

28-
- [Installation](#installation)
29-
- [Requirements](#requirements)
30-
- [Known Incompatibilities](#known-incompatibilities)
31-
- [mongodb-memory-server](#mongodb-memory-server)
32-
- [mongodb-memory-server-global](#mongodb-memory-server-global)
33-
- [mongodb-memory-server-core](#mongodb-memory-server-core)
34-
- [Configuring which mongod binary to use](#configuring-which-mongod-binary-to-use)
35-
- [Usage](#usage)
36-
- [Simple server start](#simple-server-start)
37-
- [Available options for MongoMemoryServer](#available-options-for-mongomemoryserver)
38-
- [Replica Set start](#replica-set-start)
39-
- [Available options for MongoMemoryReplSet](#available-options-for-mongomemoryreplset)
40-
- [Options which can be set via ENVIRONMENT variables](#options-which-can-be-set-via-environment-variables)
41-
- [Options which can be set via package.json's `config` section](#options-which-can-be-set-via-packagejsons-config-section)
42-
- [Simple test with MongoClient](#simple-test-with-mongoclient)
43-
- [Provide connection string to mongoose](#provide-connection-string-to-mongoose)
44-
- [Several mongoose connections simultaneously](#several-mongoose-connections-simultaneously)
45-
- [Simple Mocha/Chai test example](#simple-mochachai-test-example)
46-
- [Simple Jest test example](#simple-jest-test-example)
47-
- [AVA test runner](#ava-test-runner)
48-
- [Docker Alpine](#docker-alpine)
49-
- [Enable Debug Mode](#enable-debug-mode)
50-
- [CI](#ci)
51-
- [Contributing](#contributing)
52-
- [Credits](#credits)
53-
- [License](#license)
54-
- [Maintainers](#maintainers)
28+
- [MongoDB In-Memory Server](#mongodb-in-memory-server)
29+
- [Installation](#installation)
30+
- [Requirements](#requirements)
31+
- [Known Incompatibilities](#known-incompatibilities)
32+
- [mongodb-memory-server](#mongodb-memory-server)
33+
- [mongodb-memory-server-global](#mongodb-memory-server-global)
34+
- [mongodb-memory-server-core](#mongodb-memory-server-core)
35+
- [Configuring which mongod binary to use](#configuring-which-mongod-binary-to-use)
36+
- [Usage](#usage)
37+
- [Simple server start](#simple-server-start)
38+
- [Available options for MongoMemoryServer](#available-options-for-mongomemoryserver)
39+
- [Replica Set start](#replica-set-start)
40+
- [Available options for MongoMemoryReplSet](#available-options-for-mongomemoryreplset)
41+
- [Options which can be set via ENVIRONMENT variables](#options-which-can-be-set-via-environment-variables)
42+
- [Options which can be set via package.json's `config` section](#options-which-can-be-set-via-packagejsons-config-section)
43+
- [Simple test with MongoClient](#simple-test-with-mongoclient)
44+
- [Provide connection string to mongoose](#provide-connection-string-to-mongoose)
45+
- [Several mongoose connections simultaneously](#several-mongoose-connections-simultaneously)
46+
- [Simple Mocha/Chai test example](#simple-mochachai-test-example)
47+
- [Simple Jest test example](#simple-jest-test-example)
48+
- [AVA test runner](#ava-test-runner)
49+
- [Docker Alpine](#docker-alpine)
50+
- [Enable Debug Mode](#enable-debug-mode)
51+
- [CI](#ci)
52+
- [Contributing](#contributing)
53+
- [Credits](#credits)
54+
- [License](#license)
55+
- [Maintainers](#maintainers)
5556

5657
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
5758

@@ -294,6 +295,19 @@ Environment variables have higher priority than contents of package.json.
294295
}
295296
```
296297

298+
By default it uses the nearest (upwards) `package.json` to `process.cwd()`.
299+
To change this:
300+
301+
```ts
302+
import { findPackageJson } from "mongodb-memory-server-core/lib/util/resolve-config";
303+
304+
findPackageJson('/custom/path');
305+
306+
// OR
307+
308+
process.chdir('/custom/path'); // not recommended
309+
```
310+
297311
### Simple test with MongoClient
298312

299313
Take a look at this [test file](https://github.com/nodkz/mongodb-memory-server/blob/master/packages/mongodb-memory-server-core/src/__tests__/singleDB-test.ts).

0 commit comments

Comments
 (0)