Skip to content

Commit

Permalink
Fix unable to use package without installing NeDB (#491)
Browse files Browse the repository at this point in the history
* Fix NeDB load fail.

* changelog
  • Loading branch information
Half-Shot authored Jan 8, 2024
1 parent de44c31 commit b8d8450
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/491.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix NeDB errors if you haven't installed the nedb packages.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"homepage": "https://github.com/matrix-org/matrix-appservice-bridge#readme",
"dependencies": {
"@types/nedb": "^1.8.16",
"@alloc/quick-lru": "^5.2.0",
"@vector-im/matrix-bot-sdk": "^0.6.7-element.1",
"chalk": "^4.1.0",
Expand All @@ -55,7 +56,6 @@
"@types/extend": "^3.0.4",
"@types/jasmine": "^4.0.3",
"@types/js-yaml": "^4.0.9",
"@types/nedb": "^1.8.16",
"@types/node": "^20",
"@types/nopt": "^3.0.32",
"@types/jsbn": "^1.2.33",
Expand Down
3 changes: 1 addition & 2 deletions src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import type Datastore from "nedb";
const nedb = import("nedb");
import {promises as fs} from "fs";
import * as util from "util";
import yaml from "js-yaml";
Expand Down Expand Up @@ -1723,7 +1722,7 @@ export class Bridge {

async function loadDatabase<T extends BridgeStore>(path: string, Cls: new (db: Datastore) => T) {
try {
const datastoreFn = (await nedb).default;
const datastoreFn = (await import("nedb")).default;
return new Promise<T>((resolve, reject) => {
const dbInstance = new datastoreFn({
filename: path,
Expand Down

0 comments on commit b8d8450

Please sign in to comment.