class Lanes::Command::Server

Public Instance Methods

launch() click to toggle source
# File lib/lanes/command/server.rb, line 9
def launch
    say "Launching testing server at http://localhost:8888/", :green
    require 'lanes/api'
    Lanes::Configuration.apply

    config = ClientConfig.new
    config.invoke_all

    API.webpack = Lanes::Command::Webpack.new([], wait: false)
    API.webpack.config = config

    API.webpack.invoke_all# startup

    ::Lanes::GuardTasks.client_config = config

    # threads = []
    # Thread.abort_on_exception = true
    # threads << Thread.new { API::Root.run! }
    # threads << Thread.new do
    #     sleep 1 until API::Root.running?
    #     Lanes.logger.info "ok, ctrl-c trap registered"
    # end
    sleep(1) # give webpack a bit of time to fail if it's going to
    unless API.webpack.process.alive?
        puts API.webpack.messages
        exit 1
    end
    Guard.start # will block until complete
    API.webpack.process.stop # stop webpack after guard completes
end