Merge pull request #125 from slecache/bower

Add support for Bower
This commit is contained in:
Fabio Rehm 2014-10-15 01:16:26 -03:00
commit 837003ed48
6 changed files with 61 additions and 0 deletions

13
docs/bower.md Normal file
View File

@ -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
```

View File

@ -88,6 +88,7 @@
<li><a tabindex="-1" href="buckets/apt-cacher">apt-cacher</a></li>
<li><a tabindex="-1" href="buckets/chef">Chef</a></li>
<li><a tabindex="-1" href="buckets/composer">Composer</a></li>
<li><a tabindex="-1" href="buckets/bower">Bower</a></li>
<li><a tabindex="-1" href="buckets/pacman">Pacman</a></li>
<li><a tabindex="-1" href="buckets/npm">npm</a></li>
<li><a tabindex="-1" href="buckets/rubygems">RubyGems</a></li>

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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