Class: Lanes::Command::Server

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/lanes/command/server.rb

Instance Method Summary collapse

Instance Method Details

#launchObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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