Skip to content

Compare destination path with gulp.src files and remove missing.

License

Notifications You must be signed in to change notification settings

agarzola/gulp-deleted

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-deleted

gulp-deleted allows you to remove files from the destination folder which do not exist in the source stream. You can specify a globs with which to identify destination files that are eligible for deletion, including exlusions.

Remove any files from the destination that are no longer in source.

function assets() {
  const src = 'src/assets/**/*';
  const dest = 'dest/';
  gulp.src(src)
    .pipe(deleted({ src, dest, patterns: [ '**/*' ] }))
    .pipe(gulp.dest(dest));
}

Keep index.html in the destination even if it doesn’t exist in the source.

function assets() {
  const src = 'src/assets/**/*';
  const dest = 'dest/';
  gulp.src(src)
    .pipe(deleted({
      src,
      dest,
      patterns: [
        '**/*',
        '!index.html',
      ],
    }))
    .pipe(gulp.dest(dest));
}

Transform filenames between source and destination.

function assets() {
  const src = 'src/assets/**/*';
  const dest = 'dest/';
  gulp.src(src)
    .pipe(deleted({
      src,
      dest,
      patterns: [
        '**/*',
      ],
      // Match `.scss` files in the source to `.css` and `.css.map` files in
      // the destination.
      transforms: [
        (filename) => filename.replace(/\.scss$/, '.css'),
        (filename) => filename.replace(/\.scss$/, '.css.map'),
      ],
    }))
    .pipe(gulp.dest(dest));
}

About

Compare destination path with gulp.src files and remove missing.

Resources

License

Stars

Watchers

Forks

Packages

No packages published