Created
December 30, 2009 18:47
-
-
Save joshaven/266281 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e54079d5fabb377844da4a3b08b501f75890504c Mon Sep 17 00:00:00 2001 | |
From: Joshaven Potter <[email protected]> | |
Date: Wed, 30 Dec 2009 13:45:49 -0500 | |
Subject: [PATCH] Fix issue with dependency on .bash_profile | |
--- | |
bin/install | 21 +++++++++++++-------- | |
1 files changed, 13 insertions(+), 8 deletions(-) | |
diff --git a/bin/install b/bin/install | |
index 7b7a3e5..fb7efa9 100755 | |
--- a/bin/install | |
+++ b/bin/install | |
@@ -3,21 +3,26 @@ | |
# File: bin/install | |
# Purpose: Install system environment conducive to developing Cilantro applications. | |
# Installs: | |
-# 1) ~/.bin to PATH (adds "export PATH=~/.bin:$PATH" to .bash_profile) | |
+# 1) ~/.bin to PATH (adds "export PATH=~/.bin:$PATH" to startup script and ensures directory exits) | |
# 2) Copies bin/cilantro to /usr/local/bin/cilantro (if have sudo permission), and installs a script into ~/.bin that proxies to the current directory's bin/cilantro, or /usr/local/bin/cilantro, whichever exists first. | |
# 3) Checks out cilantro to ~/.cilantro.git | |
+# Ensure that ~/.bin exists | |
+::Dir.mkdir "#{ENV['HOME']}/.bin" unless ::File.directory? "#{ENV['HOME']}/.bin" | |
-bash_profile = File.read("#{ENV['HOME']}/.bash_profile") | |
-unless bash_profile =~ /\~\/.bin:\$PATH/ && File.directory?("#{ENV['HOME']}/.bin") | |
- open("#{ENV['HOME']}/.bash_profile", 'a') do |f| | |
- f << 'export PATH=~/.bin:$PATH' | |
+# Append the path through an export in your startup script file | |
+unless Regexp.new("#{ENV['HOME']}/.bin") === ENV['PATH'] | |
+ profile = false | |
+ ["#{ENV['HOME']}/.bashrc", "#{ENV['HOME']}/.profile", "#{ENV['HOME']}/.bash_profile"].each do |file| | |
+ profile = file if ::File.exists? file | |
end | |
- mkdir "#{ENV['HOME']}/.bin" | |
- puts "Installed ~/.bin to PATH (added to .bash_profile)" | |
+ ::File.open(profile ||= "#{ENV['HOME']}/.bash_profile", 'a') do |f| | |
+ f << "export PATH=~/.bin:$PATH\n" | |
+ end | |
+ | |
+ puts "Installed ~/.bin to PATH (added export to #{profile})" | |
end | |
- | |
if `cp #{File.dirname(__FILE__)}/cilantro /usr/local/bin/` | |
# `cp #{File.dirname(__FILE__)}/cilantro #{ENV['HOME']}/.bin` | |
puts "Installed cilantro to /usr/local/bin" | |
-- | |
1.6.4.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment