gulp-develop-server icon indicating copy to clipboard operation
gulp-develop-server copied to clipboard

Expose a method or parameter that tells you if the server is currently running

Open grimurd opened this issue 10 years ago • 2 comments

Would be great to be able to know when the server is running so i can change my build tasks accordingly.

Example if i'm building my source code and the server is running I want to pipe it to server() otherwise I'd not do it because it throws an error. Something that can be used with gulp-if would be even better.

grimurd avatar Oct 26 '15 23:10 grimurd

From reading the source i noticed that this can be achieved by using the child variable.

so my build task now looks like this:

    var server = require( 'gulp-develop-server' );

    gulp.task('build', function() {

        gulp.watch(config.src + '/**/*.*', ['build']);

        return gulp.src(config.src + '/**/*')
            .pipe($.babel())
            .pipe(gulp.dest(config.dist))
            .pipe($.if(server.child ? true : false, server(), $.util.noop()));

    });

Though this should probably be documented somewhere. And maybe add a method that returns true/false based on whether server.child is set or not.

grimurd avatar Oct 26 '15 23:10 grimurd

Hi, @Sk1Zy This plugin provided server.child and server.isChanged in such use case, as you say. But actually, these options must be provide as immutable. We consider adding a method whether the server runs success/failure at next version. Thanks.

narirou avatar Nov 03 '15 08:11 narirou