From 4ce8fc01d8c11bca63c36ffb78d29a395d08a35b Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 26 Oct 2023 23:44:36 +0200 Subject: [PATCH] Add noUse opt --- README.md | 2 ++ index.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 131be48..0d80085 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Valid `opts` keys include: - `opts.db1` (default: `false`) - uses `ssb-db2` by default, but if `true` will use `ssb-db` - your can also switch to db1 by setting the ENV `SSB_DB1=true` +- `opts.noUse` (default: `false`) + - if true then the testbot uses neither db1 nor db2 by default, leaving that up to you. Useful e.g. in case you want to control what plugins get imported along with db2. ### `TestBot.use(plugin)` diff --git a/index.js b/index.js index 5764653..71c9a92 100644 --- a/index.js +++ b/index.js @@ -33,10 +33,14 @@ function createTestBot (opts = {}) { } const createSbot = require('secret-stack')({ caps }) - .use((process.env.SSB_DB1 || opts.db1) - ? require('ssb-db') - : require('ssb-db2') - ) + + if (process.env.SSB_DB1 || opts.db1) { + createSbot.use(require('ssb-db')) + } else if (opts.noUse) { + // no use + } else { + createSbot.use(require('ssb-db2')) + } plugins.forEach(plugin => createSbot.use(plugin)) plugins = []