Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New skip_browsersync_checks flag on lucky watch #1517

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tasks/watch.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module LuckySentry
@app_built : Bool = false
@successful_compilations : Int32 = 0

def initialize(build_commands : Array(String), run_commands : Array(String), files : Array(String), @reload_browser : Bool)
def initialize(build_commands : Array(String), run_commands : Array(String), files : Array(String), @reload_browser : Bool, @skip_browsersync_checks : Bool)
@build_commands = build_commands
@run_commands = run_commands
@files = files
Expand Down Expand Up @@ -63,7 +63,7 @@ module LuckySentry
end

private def browsersync_port_is_available? : Bool
if File.executable?(`which lsof`.chomp)
if !@skip_browsersync_checks || File.executable?(`which lsof`.chomp)
io = IO::Memory.new
Process.run("lsof -i :#{BROWSERSYNC_PORT}", output: io, error: STDERR, shell: true)
io.to_s.empty?
Expand Down Expand Up @@ -203,6 +203,7 @@ class Watch < LuckyTask::Task
summary "Start and recompile project when files change"
switch :reload_browser, "Reloads browser on changes using browser-sync", shortcut: "-r"
switch :error_trace, "Show full error trace"
switch :skip_browsersync_checks, "Disables checking if the browsersync port is available."

def call
build_commands = ["crystal build ./src/start_server.cr -o bin/start_server"]
Expand All @@ -214,7 +215,8 @@ class Watch < LuckyTask::Task
files: files,
build_commands: build_commands,
run_commands: run_commands,
reload_browser: reload_browser?
reload_browser: reload_browser?,
skip_browsersync_checks: skip_browsersync_checks?
)

puts "Beginning to watch your project"
Expand Down