_base.ts 543 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * base
  3. * @author: oldj
  4. * @homepage: https://oldj.net
  5. */
  6. import assert = require('assert')
  7. import * as path from 'path'
  8. global.db_dir = path.join(__dirname, 'tmp', 'db')
  9. import { swhdb } from '@root/main/data'
  10. import Db from 'potdb'
  11. declare global {
  12. namespace NodeJS {
  13. interface Global {
  14. db_dir?: string;
  15. swhdb: Db;
  16. }
  17. }
  18. }
  19. const clearData = async () => {
  20. await swhdb.collection.hosts.remove()
  21. await swhdb.collection.trashcan.remove()
  22. await swhdb.list.tree.remove()
  23. }
  24. export {
  25. assert,
  26. clearData,
  27. }