DocUpdaterApp.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Fix any style issues and re-enable lint.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS101: Remove unnecessary use of Array.from
  6. * DS102: Remove unnecessary code created because of implicit returns
  7. * DS205: Consider reworking code to avoid use of IIFEs
  8. * DS207: Consider shorter variations of null checks
  9. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  10. */
  11. const app = require('../../../../app')
  12. module.exports = {
  13. running: false,
  14. initing: false,
  15. callbacks: [],
  16. ensureRunning(callback) {
  17. if (callback == null) {
  18. callback = function () {}
  19. }
  20. if (this.running) {
  21. return callback()
  22. } else if (this.initing) {
  23. return this.callbacks.push(callback)
  24. }
  25. this.initing = true
  26. this.callbacks.push(callback)
  27. app.listen(3003, '127.0.0.1', error => {
  28. if (error != null) {
  29. throw error
  30. }
  31. this.running = true
  32. return (() => {
  33. const result = []
  34. for (callback of Array.from(this.callbacks)) {
  35. result.push(callback())
  36. }
  37. return result
  38. })()
  39. })
  40. },
  41. }