0

I want to delete any files named .DS_Store anywhere in a directory Gulp helps to build. However, Gulp does not pass all the files through it's own pipe, so I don't think I can do clever things with vinyl here. Rather, most of the files are generated via a static site generator that Gulp calls with child_process.

The problem is, this static site generator does not have a parameter to skip these sorts of files when it encounters them in source directories; it will just blindly carry them over. I don't want these files, so I'd like to have Gulp remove them anywhere they're found.

I tried e.g. del(['output/**/.DS_Store'], cb);, but that didn't work. Any ideas?

Update: After discovering I need something fancier than del, I tried to use glob to solve this, but I must be doing it wrongly:

const glob = require('glob');
const del = require('del');

gulp.task('build', function(cb) {
    exec('pelican', function(err, stdout, stderr) {
        console.log(stdout);
        console.log(stderr);
        cb(err);
    });

    glob('output/**/.DS_Store', function(err, files) {
        files.forEach( function(file) {
            del([file]);
        });
    });
});

Update 2: No files are deleted as a result of the glob, however, I do note that if I insert console.log(file);, the expected files are output. So perhaps I'm on the right track, but doing something wrong with del...

Tohuw
  • 3,630
  • 5
  • 22
  • 24

1 Answers1

0

Turns out I was causing my own problem by combining the exec block with the glob statement. It worked once I made these separate tasks and had the task build call pelican for the exec block and rmkjunk for the glob statement.

It's worth noting this created a new problem of needing sequential vs. parallel tasks to be run, which this SO answer addresses. Hope this helps some future confused person.

Tohuw
  • 3,630
  • 5
  • 22
  • 24