gulp: Direct path (non-glob) .src streams should fail on file not found

Example: https://gist.github.com/anonymous/9774298

If it isn’t a glob it should probably fail if the file isn’t found.

Reported by heyladies via IRC

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 3
  • Comments: 43 (28 by maintainers)

Most upvoted comments

As a temporary hack, you can fs.statSync the files before you gulp.src 'em:

function statAll(files) {
  files.forEach(fs.statSync) //will trow an error if file not found
}

@stu-salsbury It’s misleading to have something like gulp.src('file.js').pipe(uglify()).pipe(gulp.dest('folder')) do nothing but say everything is okay. Technically it makes sense but from a user perspective it didn’t do what they told it to do.

Also, disregard my thoughts about directories.

I guess I just figured out that I’d prefer to see a warn-level log entry from .src:

WARN: 'file.js' not found

and if the file being absent is a possible valid case, I could squelch the warning from my gulpfile.