black-list-generator.js 773 Bytes
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

module.exports = function (grunt) {
    'use strict';

    var glob = require('glob'),
        fs = require('fs'),
        path = require('path'),
        fst = require('../tools/fs-tools.js'),
        pc = require('../configs/path');

    grunt.registerTask('black-list-generator', function () {
        process.chdir(grunt.option('dir') || '.');

        var whiteListFile = glob.sync(pc.static.whitelist + '*.txt')[0],
            blacklistFile = pc.static.blacklist + path.basename(whiteListFile),
            whiteList = fst.getData(whiteListFile);

        fst.arrayRead(whiteList, function (data) {
            fst.write(blacklistFile, data);
        });
    });
};