Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

82 lines (53 sloc) 2.167 kB
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
usage =<<USAGE
Usage: pik_install path\\to\\install
You should install to a directory that is in your system path,
or add the directory to your system path. Do not install to
your ruby's bin directory because pik will remove it from the
path when switching versions.
Example:
C:\\>path
PATH=C:\\tools;C:\\ruby\\Ruby-186-p383\\bin;C:\\WINDOWS\\system32;...
C:\\>pik_install C:\\tools
USAGE
abort usage unless ARGV.first
puts "Thank you for using pik.\n\n"
install_dir = ARGV.first
pik_home = File.join(ENV['HOME'] || ENV['USERPROFILE'], '.pik')
src_dir = File.join(File.dirname(File.dirname(__FILE__)), 'tools')
bash_install_dir = install_dir.tr('\\','/').sub(/^(.):/){|s| "/#{s[0,1].downcase}"}
mkdir_p install_dir, :verbose => true
mkdir_p pik_home, :verbose => true
old_dir = File.join(install_dir, 'pik')
old_pik = File.join(old_dir, 'pik_runner.exe')
if File.exist? old_pik
puts "cleaning up old files and directories"
rm old_pik, :verbose => true
end
begin
rmdir(old_dir, :verbose=> true) if File.exist? old_dir
rescue Errno::ENOTEMPTY
puts "warning: can't delete #{old_dir}, directory not empty"
puts "continuing install..."
end
puts "Installing to #{install_dir}\n\n"
cp File.join(src_dir, 'pik_runner.exe'), install_dir, :verbose => true
cp File.join(src_dir, 'pik.bat'), install_dir, :verbose => true
cp File.join(src_dir, 'pik.ps1'), install_dir, :verbose => true
cp File.join(src_dir, 'pik.sh'), install_dir, :verbose => true
puts "\npik is installed"
unless ENV['PATH'].downcase.include?( install_dir.downcase.gsub('/',"\\") )
system_path_msg =<<SYSTEM_PATH_MSG
The directory you installed to is not in the sytem path.
#{install_dir}
You will need to add it.
SYSTEM_PATH_MSG
puts system_path_msg
end
puts
puts bash_msg =<<BASH_MSG
if you want to use pik with git bash, add the following line to your ~/.bashrc:
[[ -s #{bash_install_dir}/pik.sh ]] && source #{bash_install_dir}/pik.sh
BASH_MSG
Jump to Line
Something went wrong with that request. Please try again.