peter-vilja / gulp-clean

A gulp plugin for removing files and folders from given paths.
178 stars 21 forks source link

Fail to clean file tree in one pass #15

Closed bkuberek closed 10 years ago

bkuberek commented 10 years ago

I have to run gulp clean multiple times to get my build directory cleaned up. I get the following error:

 ⮀ gulp clean
[02:34:32] Using gulpfile ~/Development/Projects/it/employee-portal-web/Gulpfile.js
[02:34:32] Starting 'clean'...
[02:34:32] Finished 'clean' after 6.57 ms

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: ENOENT, stat '/Users/bkuberek/Development/Projects/it/employee-portal-web/build/fonts/fontawesome-webfont.eot'

 ⮀ gulp clean 
[02:34:46] Using gulpfile ~/Development/Projects/it/employee-portal-web/Gulpfile.js
[02:34:46] Starting 'clean'...
[02:34:46] Finished 'clean' after 6.76 ms

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: ENOENT, stat '/Users/bkuberek/Development/Projects/it/employee-portal-web/build/views/people/person_profile.html'

 ⮀ gulp clean
[02:34:59] Using gulpfile ~/Development/Projects/it/employee-portal-web/Gulpfile.js
[02:34:59] Starting 'clean'...
[02:34:59] Finished 'clean' after 7.11 ms

Here is my task:

gulp.task('clean', function () {
  gulp.src([PATH.build + '/**', PATH.dist + '/**'], {read: false}).pipe(gClean({force: true}));
});
bkuberek commented 10 years ago

Turns out, I was not doing a good job in keeping my tasks in sync. So I was having race conditions.

For example:

gulp.task('build', ['clean', 'compile'], function () {...});

I was under the impression that the dependencies would run in order, which is not the case. Both clean and compile would run in parallel.

The solution, although not ideal, was to add clean as a dependency to all tasks.

mschipperheyn commented 9 years ago

Can you not

gulp.task('build', function() {
   runSequence(['clean'], ['compile']);
});