Class: Guard::HippoGuardPlugin
- Inherits:
-
Object
- Object
- Guard::HippoGuardPlugin
- Defined in:
- lib/hippo/hippo_guard_plugin.rb
Constant Summary collapse
- ROOT =
Pathname.new(__FILE__).dirname.join('..','..')
Instance Attribute Summary collapse
-
#jest ⇒ Object
readonly
Returns the value of attribute jest.
-
#threads ⇒ Object
readonly
Returns the value of attribute threads.
-
#webpack ⇒ Object
readonly
Returns the value of attribute webpack.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ HippoGuardPlugin
constructor
A new instance of HippoGuardPlugin.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HippoGuardPlugin
Returns a new instance of HippoGuardPlugin.
11 12 13 14 15 |
# File 'lib/hippo/hippo_guard_plugin.rb', line 11 def initialize( = {}) super end |
Instance Attribute Details
#jest ⇒ Object (readonly)
Returns the value of attribute jest
9 10 11 |
# File 'lib/hippo/hippo_guard_plugin.rb', line 9 def jest @jest end |
#threads ⇒ Object (readonly)
Returns the value of attribute threads
9 10 11 |
# File 'lib/hippo/hippo_guard_plugin.rb', line 9 def threads @threads end |
#webpack ⇒ Object (readonly)
Returns the value of attribute webpack
9 10 11 |
# File 'lib/hippo/hippo_guard_plugin.rb', line 9 def webpack @webpack end |
Instance Method Details
#start ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/hippo/hippo_guard_plugin.rb', line 26 def start @threads = Array.new() @webpack = WebpackDriver::DevServer.new( '--port', '8889', '--config', ROOT.join('lib','js','webpack.config.js')..to_s ) Hippo::API.webpack = @webpack roots = Hippo::Extensions.map{|ext| ext.root_path.join('client').to_s } @jest = ::ChildProcess.build( ROOT.join('node_modules/jest-cli/bin/jest.js').to_s, '--watch', '--config', ROOT.join('lib', 'js', 'jest.config.js').to_s ) @jest_output, w = IO.pipe jest.io.stdout = jest.io.stderr = w # jest.io.stdin = STDIN jest.start Thread.new do @jest_output.each_line do | l | puts l end end threads << Thread.new { Hippo::API::Root.run! } threads << Thread.new { until API::Root.running? sleep 1 end # needed to remove the Sinatra's handler trap("INT") { exit } } webpack.environment.merge!( HIPPO_EXT_ROOTS: roots.join(',') ) webpack.start sleep(1) unless webpack.alive? puts webpack. end end |
#stop ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/hippo/hippo_guard_plugin.rb', line 17 def stop webpack.stop jest.stop threads.each do |thread| thread.exit end end |