4
votes

I'm trying to move my file path globs into an object at the top of my gulpfile. After refactoring my gulpfile like this I started to get this error trigged by gulp.watch:

throw new TypeError('Arguments to path.resolve must be strings');

At the top of my gulpfile I've defined a variable srcFolder which should be the name of the folder that contains the source files for my project. Then I create a map containing the paths that are associated with each task and append this folder name to the beginning of each path. In this example my srcFolder is just called "src", and I am only seeing this error when I have an "src" directory to watch. For example, changing srcFolder to "foo" or changing gulp.watch to look at "foo" will not cause an error.

Here is a link to my gulpfile stripped down to a single task (styles). Line 70 is where I call gulp.watch. My gulp version is 3.6.2.

1

1 Answers

14
votes

It's simply poor api design. You need to pass the task list as an array, even if it is a single task.

gulp.watch(srcGlobs.style, ['styles']);

should work.