lib/kdwatch-app.rb in kdwatch-0.5.3 vs lib/kdwatch-app.rb in kdwatch-0.5.4

- old
+ new

@@ -1,7 +1,8 @@ require_relative "kdwatch/version" require 'bundler' +require 'tempfile' # Bundler.require require "bundler" require "thin" # require "guard-livereload" @@ -60,24 +61,28 @@ get "/rfc-local.css" do # insert local css here end -File.write(".Guardfile", <<GF) +guardfile = Tempfile.new("kdwatch-guard-") +guardfile.write(<<GF) guard :livereload, :port => #{ENV["KDWATCH_LRPORT"]} do watch("#{sfn}") end GF +guardfile.close +gfpath = guardfile.path +# gfpath = "#{path}.guardfile" +# File.rename(path, gfpath) rd, _wr = IO.pipe -spawn("guard -G .Guardfile", in: rd, close_others: true) +spawn("guard -G #{gfpath}", in: rd, close_others: true) # wrong: puts settings.port host = "localhost" if host == "::" # work around macOS peculiarity host = "[#{host}]" if host =~ /:/ url = "http://#{host}:#{port}" spawn("sleep 5; open #{url} || xdg-open #{url} || echo @@@ Please open #{url}") -