question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A single task in gulp.watch() using gulp.task() incorrectly logs as <anonymous>

See original GitHub issue

As discussed earlier.

Using the latest version of Gulp 4:

var gulp = require('gulp');

gulp.task('css', function () {
  return gulp.src('test.css');
});

gulp.task('watch', function () {
  gulp.watch('test.css', gulp.task('css'))
})

Results in:

[09:45:21] Starting 'watch'...
[09:45:24] Starting '<anonymous>'...
[09:45:24] Finished '<anonymous>' after 15 ms

Whereas replacing the watch task with:

gulp.task('watch', function () {
  gulp.watch('test.css', gulp.registry().get('css'))
})

Results in:

[09:52:17] Starting 'watch'...
[09:52:20] Starting 'css'...
[09:52:20] Finished 'css' after 16 ms

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
phatedcommented, Jun 11, 2016

I had some time to look into this and I couldn’t come up with a good reason why I wanted to return the unwrapped function. Instead, gulp.task('taskName') will return the wrapped function with an unwrap() method if you need to get the original function. I have the code, just need to finish it up and push it.

0reactions
phatedcommented, Jun 28, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Gulp error: The following tasks did not complete - Stack Overflow
I've seen a few example Gulp 4 examples such as this one where watchers don't seem to be accompanied by completion signals. What...
Read more >
Watching Files | gulp.js
The watch() API connects globs to tasks using a file system watcher. It watches for changes to files that match the globs and...
Read more >
Concatenate & Minify Javascript with Gulp, Improve Site ...
Create a gulp task and pass in the name 'scripts' and then a function. In this function, use gulp.src to grab the location...
Read more >
Gulp Configuration: A Beginners Guide - WebDevStudios.com
.task() – Defines a task which executes either an anonymous or callback function. .src() – Creates a stream of files.
Read more >
How do I log errors with Gulp.js? - Laracasts
I'm getting weird errors when I run my default gulp task. I tried to log the errors with plumber but I do something...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found