sapegin / grunt-webfont

SVG to webfont converter for Grunt
MIT License
1.1k stars 210 forks source link

only clean generated stylesheet files when building, not all files #302

Closed maephisto666 closed 8 years ago

maephisto666 commented 8 years ago

This is similar to #194

Consider the function cleanOutputDir in webfont.js

function cleanOutputDir(done) {
            var htmlDemoFileMask = path.join(o.destCss, o.fontBaseName + '*.{' + o.stylesheet + ',html}');
            var files = glob.sync(htmlDemoFileMask).concat(wf.generatedFontFiles(o));
            async.forEach(files, function(file, next) {
                fs.unlink(file, next);
            }, done);
        }

Var htmlDemoFileMask represents a set of files (due to wildcard symbol). So the function will delete icons.less, icons-something.less and so on. If I have a less file whose name has the same prefix, that one will be deleted as well. This could seem a strange behavior in my opinion and it could lead to unexpected results.

sapegin commented 8 years ago

Don’t mix generated files with something else in the same folder. But this code can be improved anyway. Pull requests are welcome.

maephisto666 commented 8 years ago

Ok, so the idea is

  1. use grunt-webfont to generate files in a directory that doesn't contain something else (maybe other files coming from other grunt tasks or whatsoever)
  2. Only at the end copy files from working dir to destination dir

We should work on this in our gruntfile.js