Skip to content

Commit

Permalink
Merge pull request #26 from ssbc/no-use
Browse files Browse the repository at this point in the history
Add noUse opt
  • Loading branch information
Powersource authored Nov 7, 2023
2 parents 600644d + 06a268a commit 4a8337b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.noDefaultUse` (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)`

Expand Down
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.noDefaultUse) {
// no use
} else {
createSbot.use(require('ssb-db2'))
}

plugins.forEach(plugin => createSbot.use(plugin))
plugins = []
Expand Down

0 comments on commit 4a8337b

Please sign in to comment.