concat.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. -- Horrible script to concatenate everything in /src into a single rx.lua file.
  2. -- Usage: lua tools/concat.lua [dest=rx.lua]
  3. local files = {
  4. 'src/util.lua',
  5. 'src/subscription.lua',
  6. 'src/observer.lua',
  7. 'src/observable.lua',
  8. 'src/operators/all.lua',
  9. 'src/operators/amb.lua',
  10. 'src/operators/average.lua',
  11. 'src/operators/buffer.lua',
  12. 'src/operators/catch.lua',
  13. 'src/operators/combineLatest.lua',
  14. 'src/operators/compact.lua',
  15. 'src/operators/concat.lua',
  16. 'src/operators/contains.lua',
  17. 'src/operators/count.lua',
  18. 'src/operators/defaultIfEmpty.lua',
  19. 'src/operators/distinct.lua',
  20. 'src/operators/distinctUntilChanged.lua',
  21. 'src/operators/elementAt.lua',
  22. 'src/operators/filter.lua',
  23. 'src/operators/find.lua',
  24. 'src/operators/first.lua',
  25. 'src/operators/flatMap.lua',
  26. 'src/operators/flatten.lua',
  27. 'src/operators/last.lua',
  28. 'src/operators/map.lua',
  29. 'src/operators/max.lua',
  30. 'src/operators/merge.lua',
  31. 'src/operators/min.lua',
  32. 'src/operators/pack.lua',
  33. 'src/operators/partition.lua',
  34. 'src/operators/pluck.lua',
  35. 'src/operators/reduce.lua',
  36. 'src/operators/reject.lua',
  37. 'src/operators/skip.lua',
  38. 'src/operators/skipUntil.lua',
  39. 'src/operators/skipWhile.lua',
  40. 'src/operators/sum.lua',
  41. 'src/operators/take.lua',
  42. 'src/operators/takeUntil.lua',
  43. 'src/operators/takeWhile.lua',
  44. 'src/operators/tap.lua',
  45. 'src/operators/unpack.lua',
  46. 'src/operators/unwrap.lua',
  47. 'src/operators/window.lua',
  48. 'src/operators/with.lua',
  49. 'src/schedulers/immediatescheduler.lua',
  50. 'src/schedulers/cooperativescheduler.lua',
  51. 'src/subjects/subject.lua',
  52. 'src/subjects/behaviorsubject.lua',
  53. 'src/aliases.lua'
  54. }
  55. local header = [[
  56. -- RxLua v0.0.1
  57. -- https://github.com/bjornbytes/rxlua
  58. -- MIT License
  59. ]]
  60. local footer = [[return {
  61. util = util,
  62. Subscription = Subscription,
  63. Observer = Observer,
  64. Observable = Observable,
  65. ImmediateScheduler = ImmediateScheduler,
  66. CooperativeScheduler = CooperativeScheduler,
  67. Subject = Subject,
  68. BehaviorSubject = BehaviorSubject
  69. }]]
  70. local output = ''
  71. for _, filename in ipairs(files) do
  72. local file = io.open(filename)
  73. if not file then
  74. error('error opening "' .. filename .. '"')
  75. end
  76. local str = file:read('*all')
  77. file:close()
  78. str = '\n' .. str .. '\n'
  79. str = str:gsub('\n(local[^\n]+require.[^\n]+)', '')
  80. str = str:gsub('\n(return[^\n]+)', '')
  81. str = str:gsub('^%s+', ''):gsub('%s+$', '')
  82. output = output .. str .. '\n\n'
  83. end
  84. local outputFile = arg[1] or 'rx.lua'
  85. local file = io.open(outputFile, 'w')
  86. if file then
  87. file:write(header .. output .. footer)
  88. end