helm/rake/pkg/emacs.rake

80 lines
1.9 KiB
Ruby
Raw Normal View History

2014-08-30 23:50:03 -07:00
if is_mac?
ENV["EMACS_D"] = File.expand_path("~/.emacs.d")
def emacs_reqs
2015-01-12 20:23:09 -08:00
[ "emacs --with-gnutls --cocoa",
"ispell",
"cask",
2015-01-12 20:23:09 -08:00
"markdown" ]
end
def node_reqs
%w{jshint jsonlint js-beautify git://github.com/ramitos/jsctags.git}
end
def setup
echo "Installing emacs dependencies"
emacs_reqs.each { |pkg| Package.install pkg }
end
def setup_node
echo "Installing node dependencies"
2015-02-01 23:02:56 -08:00
sh_safe "/usr/local/bin/npm install -g #{node_reqs.join(' ')}"
2015-01-12 20:23:09 -08:00
end
def setup_emacs_d
echo "Setting up emacs.d & updating cask"
github 'hlissner/emacs.d', '~/.emacs.d'
sh_safe "cd '#{ENV["EMACS_D"]}' && cask install"
end
def emacs_installed?
Dir.exists?(ENV["EMACS_D"])
end
2015-01-12 20:23:09 -08:00
#
desc "Ensure emacs 24.4 is installed & up to date"
2014-08-30 23:50:03 -07:00
task :emacs => "emacs:update"
namespace :emacs do
2015-01-12 20:23:09 -08:00
desc "Install emacs completely"
2015-02-04 22:00:33 -08:00
task :install => ["pkg:nodejs:install", :setup, :setup_node, :setup_emacs_d]
2015-01-12 20:23:09 -08:00
desc "Setup required homebrew packages"
task :setup do
setup if !emacs_installed? || ENV["FORCE"]
end
desc "Setup required node & node plugins"
task :setup_node do
setup_node if !emacs_installed? || ENV["FORCE"]
end
desc "Setup emacs.d folder, plugins and cask"
task :setup_emacs_d do
setup_emacs_d if !emacs_installed? || ENV["FORCE"]
2014-07-17 05:18:53 -07:00
end
task :update => "emacs:install" do
2015-02-01 23:02:56 -08:00
if emacs_installed? && Dir.exists?("#{ENV['EMACS_D']}/.git")
2015-01-12 20:23:09 -08:00
echo "Updating emacs.d & packages"
sh_safe "cd '#{ENV["EMACS_D"]}' && git pull && cask update"
2014-09-05 14:03:26 -07:00
2015-02-01 23:02:56 -08:00
# Update node
2015-02-04 22:00:33 -08:00
sh "/usr/local/bin/npm update -g #{node_reqs.join(' ')}"
2015-01-12 20:23:09 -08:00
end
2014-07-17 05:18:53 -07:00
end
2014-07-17 05:18:53 -07:00
task :remove do
2014-08-30 23:50:03 -07:00
echo "Uninstalling emacs"
Package.remove "emacs"
Package.remove "homebrew/dupes/tidy"
2015-01-12 20:23:09 -08:00
emacs_reqs.each { |pkg| Package.remove pkg.split.first }
2014-08-30 23:50:03 -07:00
rm_rf ENV["EMACS_D"] if Dir.exists? ENV["EMACS_D"]
2014-07-17 05:18:53 -07:00
end
2014-08-30 23:50:03 -07:00
end
end