How can I use gulp to watch for composer package updates?
-
21-12-2019 - |
Question
Composer is a great tool for dependency management but for local development it can become time consuming to keep running it to update builds. There are ways round this such as symlinking, but with build tools like gulp it seems there should be better ways to monitor changes to local libraries.
Watching a local library makes sense but composer bases it's update decisions on the latest git
commit, not on the current state of the working directory. How can I have a gulp watch
task update my dependencies?
Solution
Turns out that you can simply watch the git reference, as long as your composer
dependency is bound to a specific branch:
gulp.watch([
'/path/to/local/lib/.git/refs/heads/master',
'/path/to/other/lib/.git/refs/heads/dev',
],['composer']);
Where the composer
task is defined
var composer = require('gulp-composer');
gulp.task('composer',function(){
composer('update',{bin:'php composer.phar'});
});
Solutions which also watch packagist.org would be greatly appreciated and may even beat out my own!