-
-
Save laracasts/8659865 to your computer and use it in GitHub Desktop.
| var gulp = require('gulp'); | |
| var gutil = require('gulp-util'); | |
| var notify = require('gulp-notify'); | |
| var sass = require('gulp-ruby-sass'); | |
| var autoprefix = require('gulp-autoprefixer'); | |
| var minifyCSS = require('gulp-minify-css') | |
| var coffee = require('gulp-coffee'); | |
| var exec = require('child_process').exec; | |
| var sys = require('sys'); | |
| // Where do you store your Sass files? | |
| var sassDir = 'app/assets/sass'; | |
| // Which directory should Sass compile to? | |
| var targetCSSDir = 'public/css'; | |
| // Where do you store your CoffeeScript files? | |
| var coffeeDir = 'app/assets/coffee'; | |
| // Which directory should CoffeeScript compile to? | |
| var targetJSDir = 'public/js'; | |
| // Compile Sass, autoprefix CSS3, | |
| // and save to target CSS directory | |
| gulp.task('css', function () { | |
| return gulp.src(sassDir + '/main.sass') | |
| .pipe(sass({ style: 'compressed' }).on('error', gutil.log)) | |
| .pipe(autoprefix('last 10 version')) | |
| .pipe(gulp.dest(targetCSSDir)) | |
| .pipe(notify('CSS minified')) | |
| }); | |
| // Handle CoffeeScript compilation | |
| gulp.task('js', function () { | |
| return gulp.src(coffeeDir + '/**/*.coffee') | |
| .pipe(coffee().on('error', gutil.log)) | |
| .pipe(gulp.dest(targetJSDir)) | |
| }); | |
| // Run all PHPUnit tests | |
| gulp.task('phpunit', function() { | |
| exec('phpunit', function(error, stdout) { | |
| sys.puts(stdout); | |
| }); | |
| }); | |
| // Keep an eye on Sass, Coffee, and PHP files for changes... | |
| gulp.task('watch', function () { | |
| gulp.watch(sassDir + '/**/*.sass', ['css']); | |
| gulp.watch(coffeeDir + '/**/*.coffee', ['js']); | |
| gulp.watch('app/**/*.php', ['phpunit']); | |
| }); | |
| // What tasks does running gulp trigger? | |
| gulp.task('default', ['css', 'js', 'phpunit', 'watch']); |
@mikeerickson that's similiar to what I have, thanks! :)
FYI, I have written a gulp-phpunit plugin and it should be available in nom in the next day or so. This version makes it plain simple to call :-)
param1 = path to php binary
param2 = options (currently only contains debug flag, will be expanded in future) [optional]
gulp.task('phpunit', function() {
var options = {debug: false};
gulp.src('./app/tests/*.php').pipe(unit('./vendor/bin/phpunit',options));
});
@jeffrey My plugin does not use gulp.run so works with all versions of gulp (including current 3.5)
@zanmoskotevc Have a look at the gulp-phpunit plugin which should be active tomorrow.
The gulp-phpunit plugin is now available on nom
https://npmjs.org/package/gulp-phpunit
npm install --save-dev gulp-phpunit
@JeffreyWay Use gulp-plumber to catch those errors.
Though using gulp.run has been deprecated, as of v3.5.