clean-black-list.js 841 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. module.exports = function (grunt) {
  6. 'use strict';
  7. var fs = require('fs'),
  8. _ = require('underscore'),
  9. glob = require('glob'),
  10. fst = require('../tools/fs-tools'),
  11. pc = require('../configs/path'),
  12. removeFromFile = function (path, files) {
  13. var data = _.difference(fst.getData(path), files);
  14. fst.write(path, data);
  15. };
  16. grunt.registerTask('clean-black-list', function () {
  17. process.chdir(grunt.option('dir') || '.');
  18. var filesToRemove = grunt.option('file').split(','),
  19. files = glob.sync(pc.static.blacklist + '*.txt');
  20. _.each(files, function (file) {
  21. removeFromFile(file, filesToRemove);
  22. });
  23. });
  24. };