class Guard::LanesGuardPlugin

Constants

ROOT

Attributes

jest[R]
threads[R]
webpack[R]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method
# File lib/lanes/lanes_guard_plugin.rb, line 11
def initialize(options = {})

    super

end

Public Instance Methods

start() click to toggle source
# File lib/lanes/lanes_guard_plugin.rb, line 26
def start
    @threads = Array.new()

    @webpack = WebpackDriver::DevServer.new(
        '--port', '8889', '--config',
        ROOT.join('lib','js','webpack.config.js').expand_path.to_s
    )
    Lanes::API.webpack = @webpack

    roots = Lanes::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 {
        Lanes::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!(
        LANES_EXT_ROOTS: roots.join(',')
    )

    webpack.start

    sleep(1)

    unless webpack.alive?
        puts webpack.messages
    end




end
stop() click to toggle source
# File lib/lanes/lanes_guard_plugin.rb, line 17
def stop
    webpack.stop
    jest.stop
    threads.each do |thread|
        thread.exit
    end

end