Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- var gulp = require('gulp'),
- g = require('gulp-load-plugins')({lazy:true}), // Very useful gulp plugin that "aggregate all your installed gulp-plugins without you needing to require them individually
- args = require('yargs').argv, // Allow you to evaluate the command and params used to run this script
- run = require('run-sequence'); // This is a bit of a hackish workaround made by IverZealous
- var isWatching = !!args.watch; // If you want to use it like so: gulp --watch (this would run the default task, and set isWatching to true);
- // If you define a watch task like so, you don't need the args.isWatching above
- gulp.task('watch', ['build'], function() {
- isWatching = true;
- gulp.watch('**/*.coffee', ['coffee']);
- });
- // default task; will execute 'build' if you just run 'gulp', then be done
- gulp.task('default', ['build']);
- // Assuming you need some compilation step or something. But before doing so, run the 'git' task
- gulp.task('coffee', ['git'], function() {
- // according to the doc, you MUST return the stream to notify gulp when this task finishes
- // personally, I add mixed results with this, and had more success by calling the callback instead (see example below)
- return gulp.src('./app/**/*.coffee')
- .pipe(g.coffee())
- .pipe(gulp.dest('./build/);
- });
- // if I understand correctly, this is where you want your condition in your case
- gulp.task('git', function(done) {
- if(isWatching) {
- // Do you git stuff
- }
- // you need to notify gulp when it's done by executing the callback.
- // Alternatively, you can return a promise
- done();
- });
- // You can define a task that runs 'everything'
- gulp.task('build', ['git', 'coffee'], function() {
- // whatever else you need. This block will execute after 'git' and 'coffee' are done, in that order (because 'coffee' also depends on 'git')
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement