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 2019/12/24 13:57:22 UTC

[whimsy] branch master updated: move bundle update optimization to Rakefile

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 db13f5b  move bundle update optimization to Rakefile
db13f5b is described below

commit db13f5b8d790f69bd153a1e9520f3906c6dba95b
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Dec 24 08:56:56 2019 -0500

    move bundle update optimization to Rakefile
---
 Rakefile          | 27 +++++++++++++++++++++++++++
 config/setupmymac | 23 -----------------------
 2 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/Rakefile b/Rakefile
index f190cc5..f3ef950 100644
--- a/Rakefile
+++ b/Rakefile
@@ -41,6 +41,33 @@ task :update, [:command] do |task, args|
     passruby = sysruby
   end
 
+  require 'bundler'
+  unless Bundler.bundle_path.writable?
+    # collect up all gems and install them so the sudo password is only
+    # asked for once
+    gemlines = Dir['**/Gemfile'].
+      map {|file| File.read file}.join.scan(/^\s*gem\s.*/)
+
+    if File.exist? "asf.gemspec"
+      gemlines +=
+        File.read("asf.gemspec").scan(/add_dependency\((.*)\)/).
+        map {|(line)| "gem #{line}"}
+    end
+
+    gems = gemlines.map {|line| [line[/['"](.*?)['"]/, 1], line.strip]}.to_h
+    gems['whimsy-asf'].sub! /\bpath:.*/, "path: #{Dir.pwd.inspect}"
+
+    require 'tmpdir'
+    Dir.mktmpdir do |dir|
+      Dir.chdir dir do
+        File.write "Gemfile",
+          "source 'https://rubygems.org'\n#{gems.values.join("\n")}"
+
+        system "bundle install"
+      end
+    end
+  end
+
   # update gems
   Dir['**/Gemfile'].each do |gemfile|
     Dir.chdir File.dirname(gemfile) do
diff --git a/config/setupmymac b/config/setupmymac
index 58f66dd..3861418 100755
--- a/config/setupmymac
+++ b/config/setupmymac
@@ -395,29 +395,6 @@ end
 
 if not $root
   if force[:gems] or not File.exist?("#{WHIMSY}/Gemfile.lock")
-    # collect up all gems and install them so the sudo password is only
-    # asked for once
-    gemlines = Dir["#{WHIMSY}/**/Gemfile"].
-      map {|file| File.read file}.join.scan(/^\s*gem\s.*/)
-
-    if File.exist? "#{WHIMSY}/asf.gemspec"
-      gemlines +=
-        File.read("#{WHIMSY}/asf.gemspec").scan(/add_dependency\((.*)\)/).
-        map {|(line)| "gem #{line}"}
-    end
-
-    gems = gemlines.map {|line| [line[/['"](.*?)['"]/, 1], line.strip]}.to_h
-    gems['whimsy-asf'].sub! /\bpath:.*/, "path: #{WHIMSY.inspect}"
-
-    Dir.mktmpdir do |dir|
-      Dir.chdir dir do
-        File.write "Gemfile", 
-          "source 'https://rubygems.org'\n#{gems.values.join("\n")}"
-
-        run "bundle install"
-      end
-    end
-
     Dir.chdir WHIMSY do
       run "rake", "update"
     end