node.jsgulpgulp-concat

gulp.src().on('error', ()=>{}) is not getting triggered when file specified in src is not found


I am trying to concatinate multiple files using gulp and gulp-concat modules of npm.

The following is the code snippet I have used.

gulp.src(['../a.js', '../b.js', '../c.js'])
    .pipe(concat('destination.js'))
    .pipe(gulp.dest('destination/path/'))
    .on('error', () => {
        console.error('Error');
     })
    .on('finish', () => {
        console.log('Success');
    });

The error event listener is not getting triggered when the file for suppose b.js or anyother is not found in the specified path.

The event finish is getting triggered anyway.

How do find error such as file not found in this process?

Thanks for the help in advance


Solution

  • I finally found a solution for this from the below post

    How to make Gulp.src fail if a file is missing?

    I Used the files-exist npm package to check if all files exist or not.