Skip to content

Instantly share code, notes, and snippets.

@arnaudbreton
Last active March 25, 2020 04:45
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arnaudbreton/9517344 to your computer and use it in GitHub Desktop.
Save arnaudbreton/9517344 to your computer and use it in GitHub Desktop.
Gruntfile to trigger new Vagrant 1.5 rsync command when catching changes. Faster than Vagrant rsync-auto bundled command, mainly because Grunt only watches specified paths while Guard/Listen (used internally by Vagrant) watches the whole (sub)-folders.
terminal = require('color-terminal')
log = (error, stdout, stderr, cb) ->
if error
terminal.color('red').write stdout
else
terminal.color('green').write stdout
cb()
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-watch' # https://github.com/gruntjs/grunt-contrib-watch
grunt.loadNpmTasks 'grunt-shell' # https://github.com/sindresorhus/grunt-shell
grunt.initConfig
vagrantPath: '<path to .vagrant dir>' # TO MODIFY
watch:
src:
options:
spawn: false
files: [
'some paths...' # TO MODIFY
]
tasks: 'shell:vagrant_rsync'
shell:
vagrant_rsync:
options:
callback: log
command: 'cd <%= vagranPath %> && vagrant rsync' # --debug to get full logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment