aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/pathname.rb
diff options
context:
space:
mode:
authorMike McQuaid2014-01-04 12:49:38 +0000
committerMike McQuaid2014-01-04 13:19:20 +0000
commitb932815490c79faf1c6838d496790ae0b571da0f (patch)
tree406d136b0988d1b01501800bf218b107ad0272b1 /Library/Homebrew/extend/pathname.rb
parentf12d181433432fbc36bbdd0da1364dee7f18aa3f (diff)
downloadhomebrew-b932815490c79faf1c6838d496790ae0b571da0f.tar.bz2
Pathname: add methods to write env scripts.
Diffstat (limited to 'Library/Homebrew/extend/pathname.rb')
-rw-r--r--Library/Homebrew/extend/pathname.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index afb60610b..3c024e77d 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -383,6 +383,27 @@ class Pathname
end
end
+ # Writes an exec script that sets environment variables
+ def write_env_script target, env
+ env_export = ''
+ env.each {|key, value| env_export += "#{key}=\"#{value}\" "}
+ self.write <<-EOS.undent
+ #!/bin/bash
+ #{env_export}exec "#{target}" "$@"
+ EOS
+ end
+
+ # Writes a wrapper env script and moves all files to the dst
+ def env_script_all_files dst, env
+ dst.mkpath
+ Dir["#{self}/*"].each do |file|
+ file = Pathname.new(file)
+ dst.install_p file
+ new_file = dst+file.basename
+ file.write_env_script(new_file, env)
+ end
+ end
+
# Writes an exec script that invokes a java jar
def write_jar_script target_jar, script_name, java_opts=""
(self+script_name).write <<-EOS.undent