gulp-community / gulp-cached

A simple in-memory file cache for gulp
MIT License
452 stars 23 forks source link

Error when using gulp-load-tasks #1

Closed markgoodyear closed 10 years ago

markgoodyear commented 10 years ago

When using gulp-load-tasks, I get this error:

Object #<Object> has no method 'cached'

With the example from the homepage, the task looks like this:

gulp.task('lint', function(){
  return gulp.src(dir.src + '/scripts/**')
    .pipe(task.cached('linting'))
    .pipe(task.jshint())
    .pipe(task.jshint.reporter())
});

Cheers!

yocontra commented 10 years ago

Probably an issue with your stuff, no? The error is saying that task has no method 'cached' so your stuff didn't load it

markgoodyear commented 10 years ago

These are the gulpfiles:

Manually load:

var gulp = require('gulp');
var cached = require('gulp-cached');
var jshint = require('gulp-jshint');
gulp.task('lint', function() {
  return gulp.src("./src/*.js")
    .pipe(cached('linting'))
    .pipe(jshint())
    .pipe(jshint.reporter())
});

Auto load:

var gulp = require('gulp');
var task = require("gulp-load-tasks")();
gulp.task('lint:autoload', function() {
  return gulp.src("./src/*.js")
    .pipe(task.cached('linting'))
    .pipe(task.jshint())
    .pipe(task.jshint.reporter())
});

Both use the same source files, but the with gulp-load-tasks fails when using gulp-cached. I've switched to manually defining the tasks for now, so it's not a big issue.

yocontra commented 10 years ago

@markgoodyear Still a problem?

markgoodyear commented 10 years ago

@Contra I've just tried it and yeah, same issue. The full error is this:

TypeError: Object #<Object> has no method 'cached'
    at Gulp.<anonymous> (/Users/markgoodyear/Desktop/Gulp/gulpfile.js:211:13)
    at module.exports (/Users/markgoodyear/Desktop/Gulp/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:31:7)
    at Gulp.Orchestrator._runTask (/Users/markgoodyear/Desktop/Gulp/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/markgoodyear/Desktop/Gulp/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/markgoodyear/Desktop/Gulp/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at startGulp (/usr/local/lib/node_modules/gulp/bin/gulp.js:141:26)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:133:5
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)

As soon as I use the non auto-loaded one, it works perfectly.

yocontra commented 10 years ago

I don't do anything special in this module with the module name or anything. Would you mind debugging a bit inside gulp-load-tasks? I'm almost certain the issue would have to be there.

markgoodyear commented 10 years ago

I noticed the plugin had updated (and changed name) so I've re-installed it and seems to run fine now.

Off topic of this issue, files don't seem to be getting cached, the lint task above always runs jshint without changing the file.

yocontra commented 10 years ago

Open a new issue up for that. I use this plugin for jshint and haven't had any problems