setup-crowi.js 508 B

12345678910111213141516171819202122232425262728
  1. const helpers = require('@commons/util/helpers');
  2. const Crowi = require('@server/crowi');
  3. let _instance = null;
  4. async function createInstance() {
  5. const crowi = new Crowi(helpers.root());
  6. await crowi.initForTest();
  7. return crowi;
  8. }
  9. async function getInstance(isNewInstance) {
  10. if (isNewInstance) {
  11. return createInstance();
  12. }
  13. // initialize singleton instance
  14. if (_instance == null) {
  15. _instance = await createInstance();
  16. }
  17. return _instance;
  18. }
  19. module.exports = {
  20. getInstance,
  21. };