ProjectHistoryApp.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. import { app } from '../../../../app/js/server.js'
  12. let running = false
  13. let initing = false
  14. const callbacks = []
  15. export function ensureRunning(callback) {
  16. if (callback == null) {
  17. callback = function () {}
  18. }
  19. if (running) {
  20. return callback()
  21. } else if (initing) {
  22. return callbacks.push(callback)
  23. }
  24. initing = true
  25. callbacks.push(callback)
  26. app.listen(3054, '127.0.0.1', error => {
  27. if (error != null) {
  28. throw error
  29. }
  30. running = true
  31. return (() => {
  32. const result = []
  33. for (callback of Array.from(callbacks)) {
  34. result.push(callback())
  35. }
  36. return result
  37. })()
  38. })
  39. }