|
| 1 | +require_relative "common/common" |
| 2 | + |
| 3 | +def build_docs_folder() |
| 4 | + c = Common.new |
| 5 | + env = c.load_env |
| 6 | + cname = "#{env.namespace}-docs-build" |
| 7 | + c.run_inline %W{ |
| 8 | + docker create --name #{cname} |
| 9 | + -w /w |
| 10 | + -v jars:/root/.m2 |
| 11 | + dmohs/clojurescript |
| 12 | + lein with-profile +docs cljsbuild once |
| 13 | + } |
| 14 | + at_exit { c.run_inline %W{docker rm -f #{cname}} } |
| 15 | + env.source_file_paths.each do |src_path| |
| 16 | + c.pipe( |
| 17 | + %W{tar -c #{src_path}}, |
| 18 | + %W{docker cp - #{cname}:/w} |
| 19 | + ) |
| 20 | + end |
| 21 | + c.run_inline %W{docker start -a #{cname}} |
| 22 | + c.run_inline %W{rm -rf docs} |
| 23 | + c.run_inline %W{mkdir -p docs/examples/target} |
| 24 | + c.run_inline %W{docker cp #{cname}:/w/resources/public/target/compiled.js docs/examples/target} |
| 25 | + c.sf.foreach_static_file do |path, entry| |
| 26 | + c.run_inline %W{cp -R #{path}/#{entry} docs/examples/#{entry}} |
| 27 | + end |
| 28 | +end |
| 29 | + |
| 30 | +def test_docs() |
| 31 | + require "webrick" |
| 32 | + WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "docs/examples").start |
| 33 | +end |
| 34 | + |
| 35 | +Common.register_command({ |
| 36 | + :invocation => "build-docs", |
| 37 | + :description => "(Re-)Builds the docs/ folder.", |
| 38 | + :fn => Proc.new { |*args| build_docs_folder(*args) } |
| 39 | +}) |
| 40 | + |
| 41 | +Common.register_command({ |
| 42 | + :invocation => "test-docs", |
| 43 | + :description => "Runs an HTTP server against the docs/examples folder.", |
| 44 | + :fn => Proc.new { |*args| test_docs(*args) } |
| 45 | +}) |
0 commit comments