Last active
March 25, 2020 04:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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