You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/09/12 19:12:54 UTC

[whimsy] branch master updated: get all local paths in each Gemfile.lock; restart if any Gemfile.lock file changes

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 7f10879  get all local paths in each Gemfile.lock; restart if any Gemfile.lock file changes
7f10879 is described below

commit 7f108799728834ff061c05949bf6eea0df7ee126
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Sep 12 15:12:07 2017 -0400

    get all local paths in each Gemfile.lock;
    restart if any Gemfile.lock file changes
---
 tools/toucher.rb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/toucher.rb b/tools/toucher.rb
index aa2a7ac..9683477 100755
--- a/tools/toucher.rb
+++ b/tools/toucher.rb
@@ -16,7 +16,7 @@ Dir["#{File.expand_path('../..', __FILE__)}/**/restart.txt"].each do |restart|
   watch[File.realpath(app)] << restart
 
   if File.exist? "#{app}/Gemfile.lock"
-    paths = File.read("#{app}/Gemfile.lock")[/^PATH.*?\n\n/m].to_s
+    paths = File.read("#{app}/Gemfile.lock").scan(/^PATH.*?\n\n/m).join
     libs = paths.scan(/^\s*remote: (.*)/).flatten.map {|path| path+'/lib'}
     libs.each {|lib| watch[lib] << restart}
   end
@@ -24,8 +24,10 @@ end
 
 watched = watch.keys.select {|dir| Dir.exist? dir}
 listener = Listen.to(*watched) do |modified, added, removed|
+  restart = false
   touches = []
   (modified + added + removed).each do |file|
+    restart ||= (File.basename(file) == "Gemfile.lock")
     watch.each do |path, restarts|
       touches += restarts if file.start_with? path + '/'
     end
@@ -34,6 +36,11 @@ listener = Listen.to(*watched) do |modified, added, removed|
   touches.uniq.each do |restart|
     FileUtils.touch restart
   end
+
+  if restart
+    require 'rbconfig'
+    exec RbConfig.ruby, __FILE__, *ARGV
+  end
 end
 
 listener.ignore /~$/

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].