Sha256: 84c153481ab46b183946adeafebaa549b9e89715c28e7d3215c6e1e21f4f07dd

Contents?: true

Size: 1.64 KB

Versions: 62

Compression:

Stored size: 1.64 KB

Contents

var path = require('path');
var rimraf = require('../util/rimraf');
var fstreamIgnore = require('fstream-ignore');
var mout = require('mout');
var Q = require('q');

function removeIgnores(dir, meta) {
    var reader;
    var applyIgnores;
    var deferred = Q.defer();
    var ignored = [];
    var nonIgnored = ['bower.json'];

    // Don't ignore main files
    nonIgnored = nonIgnored.concat(meta.main || []);

    nonIgnored = nonIgnored.map(function (file) {
        return path.join(dir, file);
    });

    reader = fstreamIgnore({
        path: dir,
        type: 'Directory'
    });

    reader.addIgnoreRules(meta.ignore || []);

    // Monkey patch applyIgnores such that we get hold of all ignored files
    applyIgnores = reader.applyIgnores;
    reader.applyIgnores = function (entry) {
        var ret = applyIgnores.apply(this, arguments);

        if (!ret) {
            ignored.push(path.join(dir, entry));
        }

        return ret;
    };

    reader
    .on('child', function (entry) {
        nonIgnored.push(entry.path);
    })
    .on('error', deferred.reject)
    .on('end', function () {
        var promises;

        // Ensure that we are not ignoring files that should not be ignored!
        ignored = mout.array.unique(ignored);
        ignored = ignored.filter(function (file) {
            return nonIgnored.indexOf(file) === -1;
        });

        // Delete all the ignored files
        promises = ignored.map(function (file) {
            return Q.nfcall(rimraf, file);
        });

        return Q.all(promises)
        .then(deferred.resolve, deferred.reject);
    });

    return deferred.promise;
}

module.exports = removeIgnores;

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.6.2 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.6.1 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.6 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.19 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.18 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.17 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.16 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.15 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.14 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.13 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.12 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.11 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.10 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.9 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.8 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.7 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.6 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.5 node_modules/bower/lib/util/removeIgnores.js
trusty-festivity-extension-2.5.4 node_modules/bower/lib/util/removeIgnores.js