diff --git a/guard/jsx.rb b/guard/jsx.rb index 4fe6381a0da48..9002f12062bb0 100644 --- a/guard/jsx.rb +++ b/guard/jsx.rb @@ -5,7 +5,8 @@ module Guard class JSX < Guard def initialize(watchers=[], options={}) - super([::Guard::Watcher.new(/(app\/jsx\/.*)/)], {}) + super([::Guard::Watcher.new(%r{app/jsx/.*}), + ::Guard::Watcher.new(%r{spec/javascripts/jsx/.*})], {}) end def run_on_change(paths) @@ -15,9 +16,10 @@ def run_on_change(paths) def run_all ::Guard::UI.info "Compiling JSX" - source = 'app/jsx' - dest = 'public/javascripts/jsx' - `node_modules/.bin/babel #{source} --out-dir #{dest} --source-maps inline` + [["app/jsx", "public/javascripts/jsx"], + ["spec/javascripts/jsx", "spec/javascripts/compiled"]].each { |source, dest| + `node_modules/.bin/babel #{source} --out-dir #{dest} --source-maps inline` + } end end diff --git a/lib/tasks/js.rake b/lib/tasks/js.rake index 58e4d38d33c3c..c42b14e5fc016 100644 --- a/lib/tasks/js.rake +++ b/lib/tasks/js.rake @@ -319,17 +319,19 @@ namespace :js do desc "Compile React JSX to JS" task :jsx do - source = Rails.root + 'app/jsx' - dest = Rails.root + 'public/javascripts/jsx' - if Rails.env == 'development' - msg = `node_modules/.bin/babel #{source} --out-dir #{dest} --source-maps inline 2>&1 >/dev/null` - else - msg = `node_modules/.bin/babel #{source} --out-dir #{dest} 2>&1 >/dev/null` - end + dirs = [["#{Rails.root}/app/jsx", "#{Rails.root}/public/javascripts/jsx"], + ["#{Rails.root}/spec/javascripts/jsx", "#{Rails.root}/spec/javascripts/compiled"]] + dirs.each { |source,dest| + if Rails.env == 'development' + msg = `node_modules/.bin/babel #{source} --out-dir #{dest} --source-maps inline 2>&1 >/dev/null` + else + msg = `node_modules/.bin/babel #{source} --out-dir #{dest} 2>&1 >/dev/null` + end - unless $?.success? - raise msg - end + unless $?.success? + raise msg + end + } end desc "creates ember app bundles" diff --git a/spec/javascripts/jsx/exampleSpec.jsx b/spec/javascripts/jsx/exampleSpec.jsx new file mode 100644 index 0000000000000..b0305977f7ee9 --- /dev/null +++ b/spec/javascripts/jsx/exampleSpec.jsx @@ -0,0 +1,7 @@ +define([], () => { + module("Example JSX Spec"); + + test("this is true", () => { + equal(true, true, "yep"); + }); +});