README.md in vagrant-exec-0.2.1 vs README.md in vagrant-exec-0.3.0

- old
+ new

@@ -9,63 +9,81 @@ You will probably use the plugin if you don't want to SSH into the box to execute commands simply because your machine environment is already configured (e.g. I use ZSH and TextMate bundles to run specs/features). Example ------- -```shell +```bash ➜ vagrant exec pwd /vagrant ``` Installation ------------ -```shell +```bash ➜ vagrant plugin install vagrant-exec ``` Configuration ------------- -### Custom folder +### Custom root The root directory can be configured using Vagrantfile. ```ruby Vagrant.configure('2') do |config| config.vm.box = 'precise32' - config.exec.folder = '/custom' + config.exec.root = '/custom' end ``` -```shell +```bash ➜ vagrant exec pwd # is the same as ➜ vagrant ssh -c "cd /custom && bundle exec pwd" ``` -### Bundler +### Prepend with -You can enable bundler to prepend each command with `bundle exec`. Note that it won't be done for commands starting with `bundle` (e.g. `bundle install`). +You can tell `vagrant-exec` to prepend all the commands with custom string. ```ruby Vagrant.configure('2') do |config| config.vm.box = 'precise32' - config.exec.bundler = true + config.exec.prepend_with 'bundle exec' end ``` -```shell +```bash ➜ vagrant exec pwd # is the same as ➜ vagrant ssh -c "cd /vagrant && bundle exec pwd" +``` -➜ vagrant exec bundle install +You can also limit prepend to specific commands and combine them. + +```ruby +Vagrant.configure('2') do |config| + config.vm.box = 'precise32' + config.exec.prepend_with 'bundle exec', :only => %w(rails rspec cucumber) + config.exec.prepend_with 'rvmsudo', :only => %w(gem) +end +``` + +```bash +➜ vagrant exec rails c # is the same as -➜ vagrant ssh -c "cd /vagrant && bundle install" +➜ vagrant ssh -c "cd /vagrant && bundle exec rails c" ``` +```bash +➜ vagrant exec gem install bundler +# is the same as +➜ vagrant ssh -c "cd /vagrant && rvmsudo gem install bundler" +``` + ### Environment variables You can add environment variables to be exported before. ```ruby @@ -74,35 +92,40 @@ config.exec.env['RAILS_ENV'] = 'test' config.exec.env['RAILS_ROOT'] = '/vagrant' end ``` -```shell +```bash ➜ vagrant exec pwd # is the same as ➜ vagrant ssh -c "cd /vagrant && export RAILS_ENV=test && export RAILS_ROOT=/vagrant && pwd" ``` Acceptance tests ---------------- Before running features, you'll need to bootstrap box. -```shell +```bash ➜ bundle exec rake features:bootstrap ``` To run features, execute the following rake task. -```shell +```bash ➜ bundle exec rake features:run ``` After you're done, remove Vagrant box. -```shell +```bash ➜ bundle exec rake features:cleanup ``` + +Known issues +----------------------------- + +`vagrant-exec` cannot properly handle `-v` in command args (it's caught somewhere before plugin), so executing `vagrant exec ruby -v` will return Vagrant version rather than Ruby. As a workaround, wrap it in quotes: `vagrant exec "ruby -v"`. Note on Patches/Pull Requests ----------------------------- * Fork the project.