Gulp.run () is deprecated

I am using gulp. I want to start the connect task after the "build-dev" task has completed.
Here's what I wrote:

gulp.task('dev', [ 'build-dev' ], function() {
    return gulp.run([ 'connect' ]);
});

      

This raises a warning:

gulp.run() has been deprecated. Use task dependencies or gulp.watch task triggering instead.

      

How can I fix this?

+3


source to share


3 answers


Create "connect" as a new task with dependencies on "build-dev" and "dev"?

fooobar.com/questions/20245 / ...

Edit: okay, you.

According to this:



https://github.com/gulpjs/gulp/issues/96

There is no way to do this in gulp, but they recommend the run sequence module:

https://www.npmjs.org/package/run-sequence

+1


source


My current solution is to use promises:



var build = function() {
    return new Promise(function(fulfill, reject) {
        // assuming usage like 'build(args, callback)'
        build(args, function(err) {
            if (err) {
                console.log('build failed');
                reject(err);
            } else {
                console.log('build succeeded');
                fulfill();
            }
        });
    });
};
var connect = function() {
    return new Promise(function(fulfill, reject) {
        // assuming usage like 'connect(address, callback)'
        connect(address, function(err) {
            if (err) {
                console.log('connect failed');
                reject(err);
            } else {
                console.log('connect succeeded');
                fulfill();
            }
        });
    });
};
gulp.task('dev', function() {
    return build().then(function() {
        return connect();
    });
});

      

0


source


To use task dependencies, you must rewrite this:

gulp.task('dev', [ 'build-dev' ], function() {
  return gulp.run([ 'connect' ]);
});

      

:

gulp.task('dev', [ 'build-dev', 'connect' ]);

      

-3


source







All Articles