diff --git a/docs/bower.md b/docs/bower.md new file mode 100644 index 0000000..60777c1 --- /dev/null +++ b/docs/bower.md @@ -0,0 +1,13 @@ +# [Bower](http://bower.io/) + +Compatible with probably any type of linux guest distro, will cache guests' +`$HOME/.cache/bower` if bower is detected. + +To manually enable it: + +```ruby +Vagrant.configure("2") do |config| + config.vm.box = 'some-box-with-bower-installed' + config.cache.enable :bower +end +``` diff --git a/docs/template.html b/docs/template.html index 064014e..1f4e7af 100644 --- a/docs/template.html +++ b/docs/template.html @@ -88,6 +88,7 @@
  • apt-cacher
  • Chef
  • Composer
  • +
  • Bower
  • Pacman
  • npm
  • RubyGems
  • diff --git a/lib/vagrant-cachier/bucket.rb b/lib/vagrant-cachier/bucket.rb index 1dbf4b4..0bf6294 100644 --- a/lib/vagrant-cachier/bucket.rb +++ b/lib/vagrant-cachier/bucket.rb @@ -96,6 +96,7 @@ require_relative "bucket/rvm" require_relative "bucket/apt_cacher" require_relative "bucket/apt_lists" require_relative "bucket/composer" +require_relative "bucket/bower" require_relative "bucket/npm" require_relative "bucket/zypper" require_relative "bucket/generic" diff --git a/lib/vagrant-cachier/bucket/bower.rb b/lib/vagrant-cachier/bucket/bower.rb new file mode 100644 index 0000000..bfc1317 --- /dev/null +++ b/lib/vagrant-cachier/bucket/bower.rb @@ -0,0 +1,21 @@ +module VagrantPlugins + module Cachier + class Bucket + class Bower < Bucket + def self.capability + :bower_path + end + + def install + if guest.capability?(:bower_path) + if bower_path = guest.capability(:bower_path) + user_symlink(bower_path) + end + else + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Bower') + end + end + end + end + end +end diff --git a/lib/vagrant-cachier/cap/linux/bower_path.rb b/lib/vagrant-cachier/cap/linux/bower_path.rb new file mode 100644 index 0000000..07b7b07 --- /dev/null +++ b/lib/vagrant-cachier/cap/linux/bower_path.rb @@ -0,0 +1,20 @@ +module VagrantPlugins + module Cachier + module Cap + module Linux + module BowerPath + def self.bower_path(machine) + bower_path = nil + machine.communicate.tap do |comm| + return unless comm.test('which bower') + comm.execute 'echo $HOME' do |buffer, output| + bower_path = output.chomp if buffer == :stdout + end + end + return "#{bower_path}/.cache/bower" + end + end + end + end + end +end diff --git a/lib/vagrant-cachier/capabilities.rb b/lib/vagrant-cachier/capabilities.rb index a6b46ef..0b3d06a 100644 --- a/lib/vagrant-cachier/capabilities.rb +++ b/lib/vagrant-cachier/capabilities.rb @@ -16,6 +16,11 @@ module VagrantPlugins Cap::Linux::ComposerPath end + guest_capability 'linux', 'bower_path' do + require_relative 'cap/linux/bower_path' + Cap::Linux::BowerPath + end + guest_capability 'linux', 'chef_file_cache_path' do require_relative 'cap/linux/chef_file_cache_path' Cap::Linux::ChefFileCachePath