Skip to content

By what should I replace gulp.run ? #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
edi9999 opened this issue May 12, 2014 · 8 comments
Closed

By what should I replace gulp.run ? #458

edi9999 opened this issue May 12, 2014 · 8 comments

Comments

@edi9999
Copy link

edi9999 commented May 12, 2014

Hi I have the following tasks:

gulp.task('watch', function () {
    gulp.src(paths.coffee)
        .pipe(watch(function(files) {
            var f=files.pipe(coffee())
                .pipe(gulp.dest(paths.js))
            gulp.run('jasmine');
            gulp.run('livereload');
            return f;
        }));
    gulp.src(paths.stylus)
        .pipe(watch(function(files){
            var f=gulp.src(paths.mainStylus)
                .pipe(stylus())
            f
                .pipe(gulp.dest(paths.css))
            gulp.run('livereload');
            return f;
        }))
});
gulp.task('livereload',function(cb)
        {
            server.changed('SpecRunner.html');
            cb()
        })

gulp.task('jasmine', function(cb) {
...
});

How should I in that sample, replace the run method which is currently deprecated ?

@sindresorhus
Copy link
Contributor

Questions are better suited for StackOverflow.

But you can use .start instead of .run https://github.com/orchestrator/orchestrator/#orchestratorstarttasks-cb

@robrich
Copy link
Contributor

robrich commented May 12, 2014

On your way to stack overflow, try one of these:

  • use .start() instead of .run() -- 98% of the time you shouldn't do this
  • change it to this: gulp.watch(['globs'], ['array','of','tasks'])

@dman777
Copy link

dman777 commented Nov 6, 2014

@sindresorhus Do you intend for .start to be used since you mentioned this? it's not in the api of Gulp. The reason being, not sure if using this will cause breakage in Gulp 4.0 and stackflow doesn't have any answers to this(but many of the same question).

@yocontra
Copy link
Member

yocontra commented Nov 6, 2014

This is an issue of bad code organization, not something to do with .start().

You want something like this:

function reload() {
  server.changed('SpecRunner.html');
}

gulp.task('watch', function() {
  gulp.src(paths.coffee)
    .pipe(watch(function(files) {
      return files.pipe(coffee())
        .pipe(gulp.dest(paths.js))
        .once('end', reload);
    }));

  gulp.src(paths.stylus)
    .pipe(watch(function(files) {
      return gulp.src(paths.mainStylus)
        .pipe(stylus())
        .pipe(gulp.dest(paths.css))
        .once('end', reload);
    }))
});

@dman777
Copy link

dman777 commented Nov 6, 2014

I see gulp.start() being used in production environments and all over stackoverflow, and it would be nice to have some clarification on start and if the
https://medium.com/@contrahacks/gulp-3828e8126466

Orchestrator is undergoing a huge overhaul

is going to make start deprecated? as far as Orchestrator being overhauled, there is nothing listed in it's milestone page on github. At this point, clarification on start is important to plan for breakage when 4.0 comes out.

@yocontra
Copy link
Member

yocontra commented Nov 6, 2014

@dman777 Here is my answer: don't use .start, you don't need it. It's an internal function used by the CLI. It doesn't need to be deprecated because it is already undocumented and marked as internal. It has been since version 1.0 almost a year ago. Named functions work perfectly fine. There is no reason to make something a task unless you intend to call it from the CLI. Even if you need to call it from the CLI, you can still use named functions.

Repeat after me:

Use functions. You don't need .start().
Use functions. You don't need .start().
Use functions. You don't need .start().

@phated
Copy link
Member

phated commented Nov 6, 2014

The 4.0 branch already has start removed. Did i mention you should start using the 4.0 branch and submit issues for us so we can ship it?

@dman777
Copy link

dman777 commented Nov 6, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants