Skip to content

Instantly share code, notes, and snippets.

@rmcc13
Created December 6, 2014 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmcc13/7257cea0676bfa33cc6f to your computer and use it in GitHub Desktop.
Save rmcc13/7257cea0676bfa33cc6f to your computer and use it in GitHub Desktop.
gulpfile with tasks to lint itself and restart gulp process on change
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jshintStylish = require('jshint-stylish');
/* required for restarting gulp task */
var spawn = require('child_process').spawn;
/* used to track if a gulp process is already running */
var p;
/* task to restart gulp process */
gulp.task('restart-me', function() {
/* if p is defined, a gulp process is already
running, kill current process befor starting
a new one */
if (p) { p.kill(); }
/* start new gulp process */
p = spawn('gulp', ['dev'], {stdio: 'inherit'});
});
/* task to lint this file */
gulp.task('lint-me', function() {
gulp.src('./gulpfile.js')
.pipe(jshint())
.pipe(jshint.reporter(jshintStylish));
});
/* watch this file, on change, lint then restart gulp */
gulp.task('watch-me', function() {
gulp.watch('./gulpfile.js', ['lint-me', 'restart-me']);
});
/* dev tasks */
gulp.task('dev', ['watch-me']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment