diff --git a/.gitignore b/.gitignore index a50c5ad..da0ab7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /evm-*.gem -/bin/emacs -/bin/evm-emacs +/bin/* +!bin/evm \ No newline at end of file diff --git a/lib/evm.rb b/lib/evm.rb index acf77df..61bdc33 100644 --- a/lib/evm.rb +++ b/lib/evm.rb @@ -3,8 +3,9 @@ module Evm ROOT_PATH = File.expand_path('..', File.dirname(__FILE__)) LOCAL_PATH = File.join('/', 'usr', 'local', 'evm') - EMACS_PATH = File.join(ROOT_PATH, 'bin', 'emacs') - EVM_EMACS_PATH = File.join(ROOT_PATH, 'bin', 'evm-emacs') + EMACS_BIN_PATH = File.join(ROOT_PATH, 'bin') + EMACS_PATH = File.join(EMACS_BIN_PATH, 'emacs') + EVM_EMACS_PATH = File.join(EMACS_BIN_PATH, 'evm-emacs') def self.abort(*args) STDERR.puts args.join(' ') diff --git a/lib/evm/package.rb b/lib/evm/package.rb index 2e10617..390482a 100644 --- a/lib/evm/package.rb +++ b/lib/evm/package.rb @@ -22,7 +22,28 @@ def bin end end + def extra_binaries + bin_path = if Evm::Os.osx? + File.join(path, 'Emacs.app', 'Contents', 'MacOS', 'bin') + else + File.join(path, 'bin') + end + + Dir.glob(File.join(bin_path, "*")) + end + + def clear_bin_dir + current = Dir.glob(File.join(Evm::EMACS_BIN_PATH, '*')).reject do |bin_path| + File.basename(bin_path) == "evm" + end + + FileUtils.rm_f(current) + end + def use! + clear_bin_dir + + FileUtils.ln_sf(extra_binaries, Evm::EMACS_BIN_PATH) FileUtils.ln_sf(bin, Evm::EVM_EMACS_PATH) unless File.symlink?(Evm::EMACS_PATH) FileUtils.ln_sf(Evm::EVM_EMACS_PATH, Evm::EMACS_PATH)