MadGenius88
2/6/2017 - 6:38 PM

Gulp Task to run PHPUnit from a Vagrant VM Raw

Gulp Task to run PHPUnit from a Vagrant VM Raw

var gulp = require('gulp'),
    sys = require('sys'),
    ssh2 = require('ssh2');

gulp.task('phpunit', function() {
    var ssh = new ssh2(); 
    
    ssh.on('ready', function () {
        ssh.exec('cd /vagrant; phpunit', {}, function (err, stream) {
        
            stream.on('data', function (data, extended) {
                sys.puts(data);
            });
            
            stream.on('end', function () {
                ssh.end();
            });
            
        });
    });
    
    ssh.connect({
        host: '127.0.0.1',
        port: 2222,
        username: 'vagrant',
        password: 'vagrant'
    }); 
});

gulp.task('default', function() {
    gulp.watch('app/**/*.php', { debounceDelay: 2000 }, ['phpunit']);
});