Last active
August 29, 2015 14:18
-
-
Save joemaller/87723dd885d81da78a8c to your computer and use it in GitHub Desktop.
A proof-of-concept gulpfile that reloads itself onchange. Not especially stable and leaves an orphan gulp process, but useful for quickly iterating a gulpfile.
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
'use strict'; | |
var gulp = require('gulp'); | |
var spawn = require('child_process').spawn; | |
/** | |
* gulpfile-reload auto-reloads this gulpfile, called from 'watch' | |
* This leaves an orphaned gulp process running after `gulp watch` exits | |
*/ | |
gulp.task('gulpfile-reload', function() { | |
spawn('gulp', ['watch'], {stdio: 'inherit'}); | |
process.exit(); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch('gulpfile.js', ['gulpfile-reload']); | |
}); |
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
{ | |
"name": "gulpfile-reload", | |
"version": "0.0.0", | |
"private": true, | |
"author": "Joe Maller <joe@joemaller.com>", | |
"license": "MIT", | |
"devDependencies": { | |
"gulp": "^3.8.*" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you don't take care of previous spawned child you'll keep adding new processes ...
try something like