traceur-rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +8 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +87 -0
  10. data/Rakefile +2 -0
  11. data/lib/js/compile.js +31 -0
  12. data/lib/traceur-rb.rb +1 -0
  13. data/lib/traceur.rb +43 -0
  14. data/lib/traceur/compilation_options.rb +65 -0
  15. data/lib/traceur/compiler.rb +33 -0
  16. data/lib/traceur/configuration.rb +47 -0
  17. data/lib/traceur/node.rb +26 -0
  18. data/lib/traceur/node/command_result.rb +28 -0
  19. data/lib/traceur/node/runner.rb +40 -0
  20. data/lib/traceur/version.rb +3 -0
  21. data/spec/examples/classes.js +12 -0
  22. data/spec/integration/examples_spec.rb +28 -0
  23. data/spec/spec_helper.rb +1 -0
  24. data/spec/traceur/compilation_options_spec.rb +31 -0
  25. data/spec/traceur/configuration_spec.rb +54 -0
  26. data/spec/traceur/node_spec.rb +15 -0
  27. data/traceur-rb.gemspec +25 -0
  28. data/vendor/node_modules/.bin/traceur +3 -0
  29. data/vendor/node_modules/traceur/README.md +40 -0
  30. data/vendor/node_modules/traceur/bin/traceur-runtime.js +2101 -0
  31. data/vendor/node_modules/traceur/bin/traceur.js +23034 -0
  32. data/vendor/node_modules/traceur/node_modules/.bin/semver +125 -0
  33. data/vendor/node_modules/traceur/node_modules/commander/Readme.md +208 -0
  34. data/vendor/node_modules/traceur/node_modules/commander/index.js +852 -0
  35. data/vendor/node_modules/traceur/node_modules/commander/package.json +40 -0
  36. data/vendor/node_modules/traceur/node_modules/q-io/.npmignore +1 -0
  37. data/vendor/node_modules/traceur/node_modules/q-io/.travis.yml +3 -0
  38. data/vendor/node_modules/traceur/node_modules/q-io/CHANGES.md +122 -0
  39. data/vendor/node_modules/traceur/node_modules/q-io/LICENSE +19 -0
  40. data/vendor/node_modules/traceur/node_modules/q-io/README.md +928 -0
  41. data/vendor/node_modules/traceur/node_modules/q-io/buffer-stream.js +59 -0
  42. data/vendor/node_modules/traceur/node_modules/q-io/coverage-report.js +44 -0
  43. data/vendor/node_modules/traceur/node_modules/q-io/deprecate.js +51 -0
  44. data/vendor/node_modules/traceur/node_modules/q-io/fs-boot.js +307 -0
  45. data/vendor/node_modules/traceur/node_modules/q-io/fs-common.js +499 -0
  46. data/vendor/node_modules/traceur/node_modules/q-io/fs-mock.js +547 -0
  47. data/vendor/node_modules/traceur/node_modules/q-io/fs-root.js +105 -0
  48. data/vendor/node_modules/traceur/node_modules/q-io/fs.js +355 -0
  49. data/vendor/node_modules/traceur/node_modules/q-io/fs2http.js +65 -0
  50. data/vendor/node_modules/traceur/node_modules/q-io/http-apps.js +152 -0
  51. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/chain.js +24 -0
  52. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/content.js +93 -0
  53. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/cookie.js +154 -0
  54. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/decorators.js +178 -0
  55. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/fs.js +417 -0
  56. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/html.js +58 -0
  57. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/json.js +78 -0
  58. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/negotiate.js +120 -0
  59. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/proxy.js +27 -0
  60. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/redirect.js +209 -0
  61. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/route.js +125 -0
  62. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/status.js +175 -0
  63. data/vendor/node_modules/traceur/node_modules/q-io/http-cookie.js +75 -0
  64. data/vendor/node_modules/traceur/node_modules/q-io/http.js +378 -0
  65. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.npmignore +11 -0
  66. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.travis.yml +4 -0
  67. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/CHANGES.md +78 -0
  68. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/LICENSE.md +21 -0
  69. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/README.md +1285 -0
  70. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/collections.js +22 -0
  71. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/dict.js +142 -0
  72. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-map.js +57 -0
  73. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-set.js +183 -0
  74. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js +261 -0
  75. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-map.js +186 -0
  76. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-order.js +55 -0
  77. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-set.js +59 -0
  78. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/heap.js +236 -0
  79. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/iterator.js +371 -0
  80. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/list.js +435 -0
  81. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/array-changes.js +247 -0
  82. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/map-changes.js +147 -0
  83. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/property-changes.js +448 -0
  84. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/range-changes.js +139 -0
  85. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-map.js +79 -0
  86. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-set.js +142 -0
  87. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/map.js +60 -0
  88. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/multi-map.js +41 -0
  89. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/package.json +12 -0
  90. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync +7 -0
  91. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync.patch +48 -0
  92. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/weak-map.js +590 -0
  93. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/package.json +49 -0
  94. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/set.js +173 -0
  95. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-array.js +274 -0
  96. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-function.js +59 -0
  97. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-object.js +538 -0
  98. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-regexp.js +14 -0
  99. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim.js +6 -0
  100. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-map.js +49 -0
  101. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-set.js +51 -0
  102. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array.js +269 -0
  103. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-map.js +61 -0
  104. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-set.js +736 -0
  105. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/tree-log.js +40 -0
  106. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/weak-map.js +1 -0
  107. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/LICENSE +19 -0
  108. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/README.md +66 -0
  109. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/mime.js +114 -0
  110. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/package.json +35 -0
  111. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/test.js +84 -0
  112. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/mime.types +1588 -0
  113. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/node.types +77 -0
  114. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/CHANGES +15 -0
  115. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/LICENSE +19 -0
  116. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/README +96 -0
  117. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/lib/mimeparse.js +166 -0
  118. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/package.json +43 -0
  119. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/CONTRIBUTING.md +40 -0
  120. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/LICENSE +19 -0
  121. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/README.md +813 -0
  122. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/compare-with-callbacks.js +71 -0
  123. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/scenarios.js +36 -0
  124. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/package.json +93 -0
  125. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/q.js +1937 -0
  126. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/queue.js +35 -0
  127. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/.gitmodules +6 -0
  128. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/History.md +36 -0
  129. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Makefile +7 -0
  130. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Readme.md +38 -0
  131. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/benchmark.js +32 -0
  132. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/examples.js +39 -0
  133. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/index.js +2 -0
  134. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/lib/querystring.js +123 -0
  135. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/package.json +19 -0
  136. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.gitmodules +3 -0
  137. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.npmignore +3 -0
  138. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/History.md +128 -0
  139. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Makefile +53 -0
  140. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Readme.md +61 -0
  141. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/bin/expresso +856 -0
  142. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/api.html +1080 -0
  143. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.html +377 -0
  144. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.md +290 -0
  145. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
  146. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
  147. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/bar.js +4 -0
  148. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/foo.js +16 -0
  149. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/package.json +12 -0
  150. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/assert.test.js +91 -0
  151. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/async.test.js +12 -0
  152. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/bar.test.js +13 -0
  153. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/foo.test.js +14 -0
  154. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/http.test.js +146 -0
  155. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
  156. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
  157. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/.gitmodules +3 -0
  158. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/History.md +22 -0
  159. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Makefile +6 -0
  160. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Readme.md +248 -0
  161. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/examples/runner.js +53 -0
  162. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/index.js +2 -0
  163. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/eql.js +91 -0
  164. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/should.js +548 -0
  165. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/package.json +8 -0
  166. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/test/should.test.js +358 -0
  167. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/test/querystring.test.js +133 -0
  168. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.npmignore +3 -0
  169. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.travis.yml +4 -0
  170. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/LICENSE.md +20 -0
  171. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/README.md +33 -0
  172. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/package.json +37 -0
  173. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/test/url2-spec.js +125 -0
  174. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/url2.js +151 -0
  175. data/vendor/node_modules/traceur/node_modules/q-io/package.json +51 -0
  176. data/vendor/node_modules/traceur/node_modules/q-io/reader.js +133 -0
  177. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/boot-directory-spec.js +47 -0
  178. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/contains-spec.js +11 -0
  179. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/fixtures/hello.txt +1 -0
  180. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/issues/1-spec.js +33 -0
  181. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/make-tree-spec.js +92 -0
  182. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/append-spec.js +41 -0
  183. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/copy-tree-spec.js +57 -0
  184. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/fixture/hello.txt +1 -0
  185. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/link-spec.js +70 -0
  186. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/make-tree-spec.js +109 -0
  187. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/merge-spec.js +67 -0
  188. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/move-spec.js +219 -0
  189. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/object-spec.js +20 -0
  190. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/range-spec.js +26 -0
  191. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/read-spec.js +40 -0
  192. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-directory-spec.js +37 -0
  193. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-tree-spec.js +39 -0
  194. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/root-spec.js +32 -0
  195. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/stat-spec.js +26 -0
  196. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/symbolic-link-spec.js +86 -0
  197. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/working-directory-spec.js +31 -0
  198. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/write-spec.js +73 -0
  199. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.js +23 -0
  200. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.txt +1 -0
  201. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/read-spec.js +22 -0
  202. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/relative-spec.js +25 -0
  203. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/reroot-spec.js +45 -0
  204. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/write-spec.js +38 -0
  205. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/cookie-spec.js +52 -0
  206. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/directory-list-spec.js +86 -0
  207. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/01234.txt +1 -0
  208. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/1234.txt +1 -0
  209. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/5678.txt +0 -0
  210. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/9012/3456.txt +0 -0
  211. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/hosts-spec.js +49 -0
  212. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/interpret-range-spec.js +47 -0
  213. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/partial-range-spec.js +186 -0
  214. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/proxy-spec.js +82 -0
  215. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/symbolic-link-spec.js +110 -0
  216. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/agent-spec.js +96 -0
  217. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/basic-spec.js +96 -0
  218. data/vendor/node_modules/traceur/node_modules/q-io/spec/lib/jasmine-promise.js +42 -0
  219. data/vendor/node_modules/traceur/node_modules/q-io/writer.js +111 -0
  220. data/vendor/node_modules/traceur/node_modules/semver/.npmignore +1 -0
  221. data/vendor/node_modules/traceur/node_modules/semver/LICENSE +27 -0
  222. data/vendor/node_modules/traceur/node_modules/semver/Makefile +24 -0
  223. data/vendor/node_modules/traceur/node_modules/semver/README.md +158 -0
  224. data/vendor/node_modules/traceur/node_modules/semver/bin/semver +125 -0
  225. data/vendor/node_modules/traceur/node_modules/semver/foot.js +6 -0
  226. data/vendor/node_modules/traceur/node_modules/semver/head.js +2 -0
  227. data/vendor/node_modules/traceur/node_modules/semver/package.json +31 -0
  228. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js +1039 -0
  229. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js.gz +0 -0
  230. data/vendor/node_modules/traceur/node_modules/semver/semver.js +1043 -0
  231. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js +1 -0
  232. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js.gz +0 -0
  233. data/vendor/node_modules/traceur/node_modules/semver/test/amd.js +15 -0
  234. data/vendor/node_modules/traceur/node_modules/semver/test/gtr.js +173 -0
  235. data/vendor/node_modules/traceur/node_modules/semver/test/index.js +584 -0
  236. data/vendor/node_modules/traceur/node_modules/semver/test/ltr.js +174 -0
  237. data/vendor/node_modules/traceur/node_modules/semver/test/no-module.js +19 -0
  238. data/vendor/node_modules/traceur/package.json +64 -0
  239. data/vendor/node_modules/traceur/src/node/System.js +31 -0
  240. data/vendor/node_modules/traceur/src/node/api.js +124 -0
  241. data/vendor/node_modules/traceur/src/node/command.js +141 -0
  242. data/vendor/node_modules/traceur/src/node/compile-single-file.js +69 -0
  243. data/vendor/node_modules/traceur/src/node/compiler.js +116 -0
  244. data/vendor/node_modules/traceur/src/node/deferred.js +110 -0
  245. data/vendor/node_modules/traceur/src/node/file-util.js +73 -0
  246. data/vendor/node_modules/traceur/src/node/getopt.js +147 -0
  247. data/vendor/node_modules/traceur/src/node/inline-module.js +149 -0
  248. data/vendor/node_modules/traceur/src/node/interpreter.js +33 -0
  249. data/vendor/node_modules/traceur/src/node/nodeLoader.js +41 -0
  250. data/vendor/node_modules/traceur/src/node/require.js +85 -0
  251. data/vendor/node_modules/traceur/src/node/to-amd-compiler.js +33 -0
  252. data/vendor/node_modules/traceur/src/node/to-commonjs-compiler.js +33 -0
  253. data/vendor/node_modules/traceur/src/node/traceur.js +32 -0
  254. data/vendor/node_modules/traceur/traceur +3 -0
  255. metadata +359 -0
@@ -0,0 +1,174 @@
1
+ var tap = require('tap');
2
+ var test = tap.test;
3
+ var semver = require('../semver.js');
4
+ var ltr = semver.ltr;
5
+
6
+ test('\nltr tests', function(t) {
7
+ // [range, version, loose]
8
+ // Version should be less than range
9
+ [
10
+ ['~1.2.2', '1.2.1'],
11
+ ['~0.6.1-1', '0.6.1-0'],
12
+ ['1.0.0 - 2.0.0', '0.0.1'],
13
+ ['1.0.0-beta.2', '1.0.0-beta.1'],
14
+ ['1.0.0', '0.0.0'],
15
+ ['>=2.0.0', '1.1.1'],
16
+ ['>=2.0.0', '1.2.9'],
17
+ ['>2.0.0', '2.0.0'],
18
+ ['0.1.20 || 1.2.4', '0.1.5'],
19
+ ['2.x.x', '1.0.0'],
20
+ ['1.2.x', '1.1.0'],
21
+ ['1.2.x || 2.x', '1.0.0'],
22
+ ['2.*.*', '1.0.1'],
23
+ ['1.2.*', '1.1.3'],
24
+ ['1.2.* || 2.*', '1.1.9999'],
25
+ ['2', '1.0.0'],
26
+ ['2.3', '2.2.2'],
27
+ ['~2.4', '2.3.0'], // >=2.4.0 <2.5.0
28
+ ['~2.4', '2.3.5'],
29
+ ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0
30
+ ['~1', '0.2.3'], // >=1.0.0 <2.0.0
31
+ ['~>1', '0.2.4'],
32
+ ['~> 1', '0.2.3'],
33
+ ['~1.0', '0.1.2'], // >=1.0.0 <1.1.0
34
+ ['~ 1.0', '0.1.0'],
35
+ ['>1.2', '1.2.0'],
36
+ ['> 1.2', '1.2.1'],
37
+ ['1', '0.0.0beta', true],
38
+ ['~v0.5.4-pre', '0.5.4-alpha'],
39
+ ['~v0.5.4-pre', '0.5.4-alpha'],
40
+ ['=0.7.x', '0.6.0'],
41
+ ['=0.7.x', '0.6.0-asdf'],
42
+ ['>=0.7.x', '0.6.0'],
43
+ ['~1.2.2', '1.2.1'],
44
+ ['1.0.0 - 2.0.0', '0.2.3'],
45
+ ['1.0.0', '0.0.1'],
46
+ ['>=2.0.0', '1.0.0'],
47
+ ['>=2.0.0', '1.9999.9999'],
48
+ ['>=2.0.0', '1.2.9'],
49
+ ['>2.0.0', '2.0.0'],
50
+ ['>2.0.0', '1.2.9'],
51
+ ['2.x.x', '1.1.3'],
52
+ ['1.2.x', '1.1.3'],
53
+ ['1.2.x || 2.x', '1.1.3'],
54
+ ['2.*.*', '1.1.3'],
55
+ ['1.2.*', '1.1.3'],
56
+ ['1.2.* || 2.*', '1.1.3'],
57
+ ['2', '1.9999.9999'],
58
+ ['2.3', '2.2.1'],
59
+ ['~2.4', '2.3.0'], // >=2.4.0 <2.5.0
60
+ ['~>3.2.1', '2.3.2'], // >=3.2.1 <3.3.0
61
+ ['~1', '0.2.3'], // >=1.0.0 <2.0.0
62
+ ['~>1', '0.2.3'],
63
+ ['~1.0', '0.0.0'], // >=1.0.0 <1.1.0
64
+ ['>1', '1.0.0'],
65
+ ['2', '1.0.0beta', true],
66
+ ['>1', '1.0.0beta', true],
67
+ ['> 1', '1.0.0beta', true],
68
+ ['=0.7.x', '0.6.2'],
69
+ ['>=0.7.x', '0.6.2']
70
+ ].forEach(function(tuple) {
71
+ var range = tuple[0];
72
+ var version = tuple[1];
73
+ var loose = tuple[2] || false;
74
+ var msg = 'ltr(' + version + ', ' + range + ', ' + loose + ')';
75
+ t.ok(ltr(version, range, loose), msg);
76
+ });
77
+ t.end();
78
+ });
79
+
80
+ test('\nnegative ltr tests', function(t) {
81
+ // [range, version, loose]
82
+ // Version should NOT be greater than range
83
+ [
84
+ ['~ 1.0', '1.1.0'],
85
+ ['~0.6.1-1', '0.6.1-1'],
86
+ ['1.0.0 - 2.0.0', '1.2.3'],
87
+ ['1.0.0 - 2.0.0', '2.9.9'],
88
+ ['1.0.0', '1.0.0'],
89
+ ['>=*', '0.2.4'],
90
+ ['', '1.0.0', true],
91
+ ['*', '1.2.3'],
92
+ ['*', 'v1.2.3-foo'],
93
+ ['>=1.0.0', '1.0.0'],
94
+ ['>=1.0.0', '1.0.1'],
95
+ ['>=1.0.0', '1.1.0'],
96
+ ['>1.0.0', '1.0.1'],
97
+ ['>1.0.0', '1.1.0'],
98
+ ['<=2.0.0', '2.0.0'],
99
+ ['<=2.0.0', '1.9999.9999'],
100
+ ['<=2.0.0', '0.2.9'],
101
+ ['<2.0.0', '1.9999.9999'],
102
+ ['<2.0.0', '0.2.9'],
103
+ ['>= 1.0.0', '1.0.0'],
104
+ ['>= 1.0.0', '1.0.1'],
105
+ ['>= 1.0.0', '1.1.0'],
106
+ ['> 1.0.0', '1.0.1'],
107
+ ['> 1.0.0', '1.1.0'],
108
+ ['<= 2.0.0', '2.0.0'],
109
+ ['<= 2.0.0', '1.9999.9999'],
110
+ ['<= 2.0.0', '0.2.9'],
111
+ ['< 2.0.0', '1.9999.9999'],
112
+ ['<\t2.0.0', '0.2.9'],
113
+ ['>=0.1.97', 'v0.1.97'],
114
+ ['>=0.1.97', '0.1.97'],
115
+ ['0.1.20 || 1.2.4', '1.2.4'],
116
+ ['0.1.20 || >1.2.4', '1.2.4'],
117
+ ['0.1.20 || 1.2.4', '1.2.3'],
118
+ ['0.1.20 || 1.2.4', '0.1.20'],
119
+ ['>=0.2.3 || <0.0.1', '0.0.0'],
120
+ ['>=0.2.3 || <0.0.1', '0.2.3'],
121
+ ['>=0.2.3 || <0.0.1', '0.2.4'],
122
+ ['||', '1.3.4'],
123
+ ['2.x.x', '2.1.3'],
124
+ ['1.2.x', '1.2.3'],
125
+ ['1.2.x || 2.x', '2.1.3'],
126
+ ['1.2.x || 2.x', '1.2.3'],
127
+ ['x', '1.2.3'],
128
+ ['2.*.*', '2.1.3'],
129
+ ['1.2.*', '1.2.3'],
130
+ ['1.2.* || 2.*', '2.1.3'],
131
+ ['1.2.* || 2.*', '1.2.3'],
132
+ ['1.2.* || 2.*', '1.2.3'],
133
+ ['*', '1.2.3'],
134
+ ['2', '2.1.2'],
135
+ ['2.3', '2.3.1'],
136
+ ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
137
+ ['~2.4', '2.4.5'],
138
+ ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0
139
+ ['~1', '1.2.3'], // >=1.0.0 <2.0.0
140
+ ['~>1', '1.2.3'],
141
+ ['~> 1', '1.2.3'],
142
+ ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0
143
+ ['~ 1.0', '1.0.2'],
144
+ ['>=1', '1.0.0'],
145
+ ['>= 1', '1.0.0'],
146
+ ['<1.2', '1.1.1'],
147
+ ['< 1.2', '1.1.1'],
148
+ ['1', '1.0.0beta', true],
149
+ ['~v0.5.4-pre', '0.5.5'],
150
+ ['~v0.5.4-pre', '0.5.4'],
151
+ ['=0.7.x', '0.7.2'],
152
+ ['>=0.7.x', '0.7.2'],
153
+ ['=0.7.x', '0.7.0-asdf'],
154
+ ['>=0.7.x', '0.7.0-asdf'],
155
+ ['<=0.7.x', '0.6.2'],
156
+ ['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'],
157
+ ['>=0.2.3 <=0.2.4', '0.2.4'],
158
+ ['1.0.0 - 2.0.0', '2.0.0'],
159
+ ['^1', '1.0.0-0'],
160
+ ['^3.0.0', '4.0.0'],
161
+ ['^1.0.0 || ~2.0.1', '2.0.0'],
162
+ ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'],
163
+ ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true],
164
+ ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true],
165
+ ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0']
166
+ ].forEach(function(tuple) {
167
+ var range = tuple[0];
168
+ var version = tuple[1];
169
+ var loose = tuple[2] || false;
170
+ var msg = '!ltr(' + version + ', ' + range + ', ' + loose + ')';
171
+ t.notOk(ltr(version, range, loose), msg);
172
+ });
173
+ t.end();
174
+ });
@@ -0,0 +1,19 @@
1
+ var tap = require('tap');
2
+ var test = tap.test;
3
+
4
+ test('no module system', function(t) {
5
+ var fs = require('fs');
6
+ var vm = require('vm');
7
+ var head = fs.readFileSync(require.resolve('../head.js'), 'utf8');
8
+ var src = fs.readFileSync(require.resolve('../'), 'utf8');
9
+ var foot = fs.readFileSync(require.resolve('../foot.js'), 'utf8');
10
+ vm.runInThisContext(head + src + foot, 'semver.js');
11
+
12
+ // just some basic poking to see if it did some stuff
13
+ t.type(global.semver, 'object');
14
+ t.type(global.semver.SemVer, 'function');
15
+ t.type(global.semver.Range, 'function');
16
+ t.ok(global.semver.satisfies('1.2.3', '1.2'));
17
+ t.end();
18
+ });
19
+
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "traceur",
3
+ "version": "0.0.44",
4
+ "description": "ES6 to ES5 compiler",
5
+ "keywords": [
6
+ "javascript",
7
+ "ecmascript",
8
+ "language",
9
+ "es5",
10
+ "es6",
11
+ "ES.next",
12
+ "harmony",
13
+ "compiler",
14
+ "transpiler"
15
+ ],
16
+ "author": {
17
+ "name": "Traceur Authors"
18
+ },
19
+ "license": "Apache License 2.0",
20
+ "engines": {
21
+ "node": ">=0.10"
22
+ },
23
+ "main": "./src/node/api.js",
24
+ "bin": {
25
+ "traceur": "./traceur"
26
+ },
27
+ "scripts": {
28
+ "test": "make test",
29
+ "start": "node ./demo/expressServer.js"
30
+ },
31
+ "homepage": "https://github.com/google/traceur-compiler",
32
+ "bugs": {
33
+ "url": "https://github.com/google/traceur-compiler/issues"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/google/traceur-compiler"
38
+ },
39
+ "dependencies": {
40
+ "commander": ">=1.1",
41
+ "q-io": "~1.10.6",
42
+ "semver": "*"
43
+ },
44
+ "devDependencies": {
45
+ "source-map": "0.1.30",
46
+ "mocha": ">=1.9",
47
+ "chai": ">=1.5",
48
+ "node-uuid": ">=1.4",
49
+ "rsvp": "3.0.3",
50
+ "requirejs": "~2.1.9",
51
+ "semver": "2.2.1",
52
+ "traceur": "0.0.43",
53
+ "promises-aplus-tests": "~2.0.4"
54
+ },
55
+ "subdomain": "traceur",
56
+ "readme": "[![Build Status](https://travis-ci.org/google/traceur-compiler.png)](https://travis-ci.org/google/traceur-compiler)\n\n<img src=\"https://raw.github.com/google/traceur-compiler/master/logo/tc.png\" alt=\"Traceur logo\" width=\"200px\">\n## What is Traceur?\n\nTraceur is a JavaScript.next-to-JavaScript-of-today compiler that allows you to\nuse features from the future **today**. Traceur's goal is to inform the design\nof new JavaScript features which are only valuable if they allow you to write\nbetter code. Traceur allows you to try out new and proposed\n[language features](https://github.com/google/traceur-compiler/wiki/LanguageFeatures)\ntoday, helping you say what you mean in your code while informing the standards process.\n\nJavaScript's evolution needs your input.\n[Try](https://github.com/google/traceur-compiler/wiki/GettingStarted) out the\nnew language features.\n[Tell us](http://groups.google.com/group/traceur-compiler-discuss)\nhow they work for you and what's still causing you to use more boilerplate and\n\"design patterns\" than you prefer.\n\n## What now? What can Traceur do for me?\n\nRead the\n[Getting Started](https://github.com/google/traceur-compiler/wiki/GettingStarted)\npage to get up and running. You can use some language features right now and\neven try it out in your browser\n[here](http://google.github.io/traceur-compiler/demo/repl.html).\nJust type in some code and see what Traceur produces. For an idea of what is\navailable and what we have in the pipeline, see the\n[Language Features](https://github.com/google/traceur-compiler/wiki/LanguageFeatures)\npage.\n\nThe JSConf 2011 presentation of Traceur describes the goals of the project and\nwhat it can do today. Some documentation is on the wiki on this site.\nExtra demos are in the source repository.\n\nWe also presented Traceur at NodeConf 2011. The video is\navailable on [YouTube](http://www.youtube.com/watch?feature=player_detailpage&v=ntDZa7ekFEA).\n\nQuestions, suggestions, and comments can be directed to the\n[discussion group](http://groups.google.com/group/traceur-compiler-discuss).\n",
57
+ "readmeFilename": "README.md",
58
+ "_id": "traceur@0.0.44",
59
+ "dist": {
60
+ "shasum": "95f182a08256e3f14c622afb6fed8e2eeae06bad"
61
+ },
62
+ "_from": "traceur@",
63
+ "_resolved": "https://registry.npmjs.org/traceur/-/traceur-0.0.44.tgz"
64
+ }
@@ -0,0 +1,31 @@
1
+ // Copyright 2014 Traceur Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ 'use strict';
16
+
17
+ var fs = require('fs');
18
+ var traceur = require('./traceur.js');
19
+ var nodeLoader = require('./nodeLoader.js');
20
+ var path = require('path');
21
+ var reporter = new traceur.util.ErrorReporter();
22
+ var LoaderHooks = traceur.runtime.LoaderHooks;
23
+ var url = (path.resolve('./') + '/').replace(/\\/g, '/');
24
+ var loaderHooks = new LoaderHooks(reporter, url, nodeLoader);
25
+
26
+ var System = new traceur.runtime.TraceurLoader(loaderHooks);
27
+
28
+ Reflect.global.System = System;
29
+ System.map = System.semverMap(System.version);
30
+
31
+ module.exports = System;
@@ -0,0 +1,124 @@
1
+ // Copyright 2013 Traceur Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ // Node.js API
16
+ //
17
+ // This is what you get when you `require('traceur')`.
18
+ // It's suppose to be used by custom scripts or tools such as Grunt or Karma.
19
+
20
+ 'use strict';
21
+
22
+ var path = require('path');
23
+ var traceur = require('./traceur.js');
24
+ var AttachModuleNameTransformer =
25
+ traceur.codegeneration.module.AttachModuleNameTransformer;
26
+ var ErrorReporter = traceur.util.CollectingErrorReporter;
27
+ var FromOptionsTransformer = traceur.codegeneration.FromOptionsTransformer;
28
+ var PureES6Transformer = traceur.codegeneration.PureES6Transformer;
29
+ var Parser = traceur.syntax.Parser;
30
+ var SourceFile = traceur.syntax.SourceFile;
31
+ var SourceMapGenerator = traceur.outputgeneration.SourceMapGenerator;
32
+ var TreeWriter = traceur.outputgeneration.TreeWriter;
33
+ var traceurOptions = traceur.options;
34
+
35
+ function merge(dest) {
36
+ var src, i;
37
+ for (i = 1; i < arguments.length; i++) {
38
+ src = arguments[i];
39
+ Object.keys(src).forEach(function(key) {
40
+ dest[key] = src[key];
41
+ });
42
+ }
43
+
44
+ return dest;
45
+ }
46
+
47
+ // The absolute path to traceur-runtime.js -- the file that should be executed
48
+ // if you want to run Traceur-compiled scripts when the compiler isn't present.
49
+ var RUNTIME_PATH = path.join(__dirname, '../../bin/traceur-runtime.js');
50
+
51
+ /**
52
+ * Compile ES6 source code with Traceur.
53
+ *
54
+ * TODO(vojta): Support source maps.
55
+ *
56
+ * @param {string} content ES6 source code.
57
+ * @param {Object=} options Traceur options.
58
+ * @return {string} Transpiled ES5 code.
59
+ */
60
+ function compile(content, options) {
61
+ options = merge({
62
+ outputLanguage: 'es5',
63
+ modules: 'commonjs',
64
+ filename: '<unknown file>',
65
+ sourceMap: false,
66
+ cwd: process.cwd(),
67
+ moduleName: false
68
+ }, options || {});
69
+
70
+ var moduleName = options.moduleName;
71
+
72
+ traceurOptions.reset();
73
+ merge(traceurOptions, options);
74
+
75
+ var errorReporter = new ErrorReporter();
76
+ var sourceFile = new SourceFile(options.filename, content);
77
+ var parser = new Parser(sourceFile, errorReporter);
78
+ var tree = parser.parseModule();
79
+ var transformer;
80
+ if (moduleName === true || options.modules == 'register' || options.modules == 'inline') {
81
+ moduleName = options.filename.replace(/\.js$/, '');
82
+ moduleName = path.relative(options.cwd, moduleName).replace(/\\/g,'/');
83
+ }
84
+ if (moduleName) {
85
+ transformer = new AttachModuleNameTransformer(moduleName);
86
+ tree = transformer.transformAny(tree);
87
+ }
88
+
89
+ if (options.outputLanguage.toLowerCase() === 'es6') {
90
+ transformer = new PureES6Transformer(errorReporter);
91
+ } else {
92
+ transformer = new FromOptionsTransformer(errorReporter);
93
+ }
94
+
95
+ var transformedTree = transformer.transform(tree);
96
+
97
+ if (errorReporter.hadError()) {
98
+ return {
99
+ js: null,
100
+ errors: errorReporter.errors,
101
+ sourceMap: null
102
+ };
103
+ }
104
+
105
+ var treeWriterOptions = {};
106
+
107
+ if (options.sourceMap) {
108
+ treeWriterOptions.sourceMapGenerator = new SourceMapGenerator({
109
+ file: options.filename,
110
+ sourceRoot: null
111
+ });
112
+ }
113
+
114
+ return {
115
+ js: TreeWriter.write(transformedTree, treeWriterOptions),
116
+ errors: errorReporter.errors,
117
+ sourceMap: treeWriterOptions.sourceMap || null
118
+ };
119
+ };
120
+
121
+ // extend traceur module
122
+ module.exports = Object.create(traceur);
123
+ module.exports.compile = compile;
124
+ module.exports.RUNTIME_PATH = RUNTIME_PATH;
@@ -0,0 +1,141 @@
1
+ // Copyright 2013 Traceur Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ 'use strict';
16
+
17
+ var path = require('path');
18
+ var commandLine;
19
+ var cmdName = path.basename(process.argv[1]);
20
+ try {
21
+ commandLine = new (require('commander').Command)(cmdName);
22
+ } catch (ex) {
23
+ console.error('Commander.js is required for this to work. To install it ' +
24
+ 'run:\n\n npm install commander\n');
25
+ process.exit(1);
26
+ }
27
+ commandLine.setMaxListeners(100);
28
+
29
+ var traceur = require('./traceur.js');
30
+ var interpret = require('./interpreter.js');
31
+
32
+ // The System object requires traceur, but we want it set for everything that
33
+ // follows. The module sets global.System as a side-effect.
34
+ require('./System.js');
35
+
36
+ var rootSources = [];
37
+ commandLine.option('--script <fileName>', 'Parse as Script', function(fileName) {
38
+ rootSources.push({name: fileName, type: 'script'});
39
+ });
40
+
41
+ commandLine.option('--module <fileName>', 'Parse as Module', function(fileName) {
42
+ rootSources.push({name: fileName, type: 'module'});
43
+ });
44
+
45
+ commandLine.option('--out <FILE>', 'Compile all input files into a single file');
46
+ commandLine.option('--dir <INDIR> <OUTDIR>', 'Compile an input directory of modules into an output directory');
47
+
48
+ commandLine.option('--sourcemap', 'Generate source maps');
49
+ commandLine.on('sourcemap', function() {
50
+ commandLine.sourceMaps = traceur.options.sourceMaps = true;
51
+ });
52
+
53
+ commandLine.option('--longhelp', 'Show all known options');
54
+ commandLine.on('longhelp', function() {
55
+ commandLine.help();
56
+ process.exit();
57
+ });
58
+
59
+ // Caling process.exit when there is still characters to be flushed to stdout
60
+ // makes Windows drop those characters. We therefor wait until the buffer is
61
+ // empty before really exiting.
62
+ // Since this makes exiting async we need to manually keep track
63
+ var shouldExit = false;
64
+
65
+ function processExit() {
66
+ shouldExit = true;
67
+ var draining = 0;
68
+ function exit() {
69
+ if (!draining--)
70
+ process.exit();
71
+ }
72
+ if (process.stdout.bufferSize) {
73
+ draining += 1;
74
+ process.stdout.once('drain', exit);
75
+ }
76
+ if (process.stderr.bufferSize) {
77
+ draining += 1;
78
+ process.stderr.once('drain', exit);
79
+ }
80
+ exit();
81
+ }
82
+
83
+ commandLine.option('-v, --version', 'Show version and exit');
84
+ commandLine.on('version', function() {
85
+ process.stdout.write(System.version.split('@')[1]);
86
+ processExit();
87
+ });
88
+
89
+ commandLine.on('--help', function() {
90
+ console.log(' Examples:');
91
+ console.log('');
92
+ console.log(' $ %s a.js [args]', cmdName);
93
+ console.log(' $ %s --out compiled.js b.js c.js', cmdName);
94
+ console.log(' $ %s --dir indir outdir', cmdName);
95
+ console.log('');
96
+ });
97
+
98
+ traceur.options.addOptions(commandLine);
99
+
100
+ commandLine.usage('[options] [files]');
101
+
102
+ commandLine.command('*').action(function() {
103
+ // The callback seems to receive a "command" at the end of arguments
104
+ for (var i = 0; i < arguments.length - 1; i++) {
105
+ rootSources.push({name: arguments[i], type: 'module'});
106
+ }
107
+ });
108
+
109
+ commandLine.parse(process.argv);
110
+
111
+ if (!shouldExit && !rootSources.length) {
112
+ // TODO: Start trepl
113
+ console.error('\n Error: At least one input file is needed');
114
+ commandLine.help();
115
+ process.exit(1);
116
+ }
117
+
118
+ var compiler = require('./compiler.js');
119
+ var compileToSingleFile = compiler.compileToSingleFile;
120
+ var compileToDirectory = compiler.compileToDirectory;
121
+ var out = commandLine.out;
122
+ var dir = commandLine.dir;
123
+ if (!shouldExit) {
124
+ if (out) {
125
+ var isSingleFileCompile = /\.js$/.test(out);
126
+ if (isSingleFileCompile)
127
+ compileToSingleFile(out, rootSources, commandLine.sourceMaps);
128
+ else
129
+ compileToDirectory(out, rootSources, commandLine.sourceMaps);
130
+ } else if (dir) {
131
+ if (rootSources.length !== 1)
132
+ throw new Error('Compile all in directory requires exactly one input filename');
133
+ var compileAllJsFilesInDir =
134
+ require('./compile-single-file.js').compileAllJsFilesInDir;
135
+ compileAllJsFilesInDir(dir, rootSources[0].name, true);
136
+ } else {
137
+ rootSources.forEach(function(obj) {
138
+ interpret(path.resolve(obj.name));
139
+ });
140
+ }
141
+ }