Skip to content
This repository
Browse code

install dir check tweaks

  • Loading branch information...
commit 86ddf0874eececb20bcad2207fb1031c0d0c5292 1 parent 02b50e9
Chris Wanstrath authored May 16, 2011
22  Rakefile
@@ -3,7 +3,7 @@ require 'erb'
3 3
 desc "Install dotjs"
4 4
 task :install => 'install:all'
5 5
 
6  
-DAEMON_INSTALL_TARGET = "/usr/local/bin"
  6
+DAEMON_INSTALL_DIR = "/usr/local/bin"
7 7
 
8 8
 namespace :install do
9 9
   task :all => [ :prompt, :daemon, :agent, :chrome, :done ]
@@ -13,7 +13,7 @@ namespace :install do
13 13
     puts "\e[1m-----\e[0m"
14 14
     puts "I will install:", ""
15 15
     puts "1. The 'dotjs' Google Chrome Extension"
16  
-    puts "2. djsd(1) in #{DAEMON_INSTALL_TARGET}"
  16
+    puts "2. djsd(1) in #{DAEMON_INSTALL_DIR}"
17 17
     puts "3. com.github.dotjs in ~/Library/LaunchAgents",""
18 18
     print "Ok? (y/n) "
19 19
 
@@ -56,8 +56,8 @@ namespace :install do
56 56
   end
57 57
 
58 58
   desc "Install dotjs daemon"
59  
-  task :daemon => ["common:has_permission_to_install_dir"] do
60  
-    cp "bin/djsd", DAEMON_INSTALL_TARGET, :verbose => true, :preserve => true
  59
+  task :daemon => :install_dir_writeable do
  60
+    cp "bin/djsd", DAEMON_INSTALL_DIR, :verbose => true, :preserve => true
61 61
   end
62 62
 
63 63
   desc "Install Google Chrome extension"
@@ -77,7 +77,7 @@ namespace :uninstall do
77 77
     puts "\e[1m\e[32mdotjs\e[0m"
78 78
     puts "\e[1m-----\e[0m"
79 79
     puts "I will remove:", ""
80  
-    puts "1. djsd(1) from #{DAEMON_INSTALL_TARGET}"
  80
+    puts "1. djsd(1) from #{DAEMON_INSTALL_DIR}"
81 81
     puts "2. com.github.dotjs from ~/Library/LaunchAgents"
82 82
     puts "3. The 'dotjs' Google Chrome Extension",""
83 83
     puts "I will not remove:", ""
@@ -115,8 +115,8 @@ namespace :uninstall do
115 115
   end
116 116
 
117 117
   desc "Uninstall dotjs daemon"
118  
-  task :daemon => ["common:has_permission_to_install_dir"] do
119  
-    rm File.join(DAEMON_INSTALL_TARGET, "djsd"), :verbose => true
  118
+  task :daemon => :install_dir_writeable do
  119
+    rm File.join(DAEMON_INSTALL_DIR, "djsd"), :verbose => true
120 120
   end
121 121
 
122 122
   desc "Uninstall Google Chrome extension"
@@ -126,9 +126,9 @@ namespace :uninstall do
126 126
   end
127 127
 end
128 128
 
129  
-namespace :common do
130  
-  desc "Checking write permissions on #{DAEMON_INSTALL_TARGET}"
131  
-  task :has_permission_to_install_dir do
132  
-    raise "Error: Unable to write to #{DAEMON_INSTALL_TARGET}. Try running using 'sudo'." if not File.writable?(DAEMON_INSTALL_TARGET)
  129
+# Check write permissions on DAEMON_INSTALL_DIR
  130
+task :install_dir_writeable do
  131
+  if not File.writable?(DAEMON_INSTALL_DIR)
  132
+    abort "Error: Can't write to #{DAEMON_INSTALL_DIR}. Try again using `sudo`."
133 133
   end
134 134
 end
2  com.github.dotjs.plist
@@ -8,7 +8,7 @@
8 8
   <true/>
9 9
   <key>ProgramArguments</key>
10 10
   <array>
11  
-    <string>/usr/local/bin/djsd</string>
  11
+    <string><%= DAEMON_INSTALL_DIR %>/djsd</string>
12 12
   </array>
13 13
   <key>RunAtLoad</key>
14 14
   <true/>

0 notes on commit 86ddf08

Please sign in to comment.
Something went wrong with that request. Please try again.