Skip to content

Commit

Permalink
a real working example in js
Browse files Browse the repository at this point in the history
  • Loading branch information
galshacham committed Jan 16, 2024
1 parent ee3cdb2 commit b15a697
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "npm run -w packages/two specific-post-install"
},
"keywords": [],
"author": "",
Expand All @@ -13,5 +14,10 @@
"packages/one",
"packages/two"
],
"dependencies": {}
"dependencies": {},
"config": {
"mongodbMemoryServer": {
"disablePostinstall": true
}
}
}
7 changes: 7 additions & 0 deletions packages/two/mongo-post-install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { MongoMemoryServer } = require("mongodb-memory-server");

// Install the server and stops it, the first time will save it to cache, since inner install in workspace is not called
(async () => {
const mongoServer = await MongoMemoryServer.create();
await mongoServer.stop();
})();
2 changes: 2 additions & 0 deletions packages/two/mongo-use.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { MongoMemoryServer } = require("mongodb-memory-server");

// the real use, for example in tests
(async () => {
const mongoServer = await MongoMemoryServer.create();
console.log(mongoServer.getUri());
Expand Down
4 changes: 2 additions & 2 deletions packages/two/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "echo hello world!"
"specific-post-install": "node ./mongo-post-install.js",
"start": "node ./mongo-use.js"
},
"author": "",
"license": "ISC",
Expand Down

0 comments on commit b15a697

Please sign in to comment.