watch + merge fails with TypeError: object is not a function
See original GitHub issueI’m trying to combine watch, and merge
Here is my gulpfile (in coffee sorry), so that you understand what I’m trying to achieve:
gulp plugins
ngClassify = require 'gulp-ng-classify'
sourcemaps = require 'gulp-sourcemaps'
coffee = require 'gulp-coffee'
gutil = require 'gulp-util'
annotate = require 'gulp-ng-annotate'
concat = require 'gulp-concat'
cached = require 'gulp-cached'
remember = require 'gulp-remember'
merge = require 'merge-stream'
debug = require 'gulp-debug'
gutil = require 'gulp-util'
gulp.task 'scripts', ->
libs = gulp.src(config.files.library.js)
.pipe cached('libs')
.pipe sourcemaps.init()
.pipe concat("libs.js")
.pipe remember('libs')
coffee = gulp.src config.files.coffee
.pipe cached('coffeescripts')
.pipe sourcemaps.init()
.pipe ngClassify()
.pipe coffee().on('error', gutil.log)
.pipe annotate()
.pipe remember('coffeescripts')
.pipe concat("coffee.js")
return merge(libs, coffee)
.pipe concat("main.js")
.pipe sourcemaps.write(".")
.pipe gulp.dest 'dist'
gulp.task "watch", ->
gulp.watch(config.files.coffee, ["scripts"])
when a file change, I’m getting following error: [18:37:59] Starting ‘scripts’… [18:37:59] ‘scripts’ errored after 5.35 ms [18:37:59] TypeError: object is not a function at Gulp.<anonymous> (/data/buildbot/granlecoja/main.js:24:122) at module.exports (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:33:7) at Gulp.Orchestrator._runTask (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/orchestrator/index.js:273:3) at Gulp.Orchestrator._runStep (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/orchestrator/index.js:214:10) at Gulp.Orchestrator.start (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/orchestrator/index.js:134:8) at Gulp.<anonymous> (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/index.js:36:18) at Gaze.<anonymous> (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/index.js:18:14) at Gaze.emit (events.js:98:17) at Gaze.emit (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:129:32) at /data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:416:16 at StatWatcher._pollers.(anonymous function) (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:327:7) at StatWatcher.emit (events.js:98:17) at StatWatcher._handle.onchange (fs.js:1109:10)
I’m able to narrow the problem to the simpler config:
gulp.task 'scripts2', ->
coffee = gulp.src config.files.coffee
.pipe gulp.dest 'dist'
return merge(coffee)
gulp.task "watch", ->
gulp.watch(config.files.coffee, ["scripts2"])
which does nothing but copy the file, via a merge-stream, but in this case, script2 task does not even finish.
Issue Analytics
- State:
- Created 9 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
yeah you can’t declare that twice, that’s your problem
thanks @cognitom for looking through that
How many files are in src/*/.coffee? Can you run gulp -v as well