Using gulp-load-tasks in a gulpfile

429 Views Asked by At

I have a project that was using Grunt. I am moving it to use Gulp. My Grunt implementation was like this:

gruntfile.js
/e2e
  page.e2e.js
/tasks
  e2e.js
  /configuration
    clean.js
    concat.js

I have this approach working in Grunt. However, I now want to mimic this approach in Gulp. At this time, I have the following in Gulpfile.js

gulpfile.js

'use strict';

var gulp = require('gulp');
var tasks = require('gulp-load-tasks')('tasks');

Then, in e2e.js, I have the following:

e2e.js

var gulp = require('gulp');
var rimraf = require('gulp-rimraf');

gulp.task('clean, function(cb) {
  console.log('here');
});

When I run gulp from the command-line, I get an error that says: "Error: Task e2e can't support dependencies that is not an array of strings." I'm not sure how to fix this. I haven't even gotten to the part where I'm putting the definition of the clean task in /tasks/configuration/clean.js.

Thank you for any insights you can provide!

2

There are 2 best solutions below

0
On BEST ANSWER

You have an error in the code:

gulp.task('clean, function(cb) {
  console.log('here');
});

You forgot to close the string 'clean.

1
On

Running gulp from the command line should technically return nothing / error out since you have no default task defined (is shorthand for gulp default).

With regards to the actual message you are getting something isn't checking out with task e2e when gulp-load-tasks is pulling it in.

In regards to that structure i dunno if i'd use gulp-load-tasks, instead try:

https://www.npmjs.com/package/require-dir

oh and also to load your gulp modules (if any) check out:

https://www.npmjs.com/package/gulp-load-plugins

Need more info, what's in your e2e file?