Skip to content

Commit

Permalink
Ignore does now not apply to any file in main #547
Browse files Browse the repository at this point in the history
  • Loading branch information
mokkabonna authored and sheerun committed Jun 20, 2014
1 parent 1690dd4 commit b8df184
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/core/resolvers/Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Resolver.prototype._applyPkgMeta = function (meta) {
}

// Otherwise remove them from the temp dir
return removeIgnores(this._tempDir, meta.ignore)
return removeIgnores(this._tempDir, meta)
.then(function () {
return meta;
});
Expand Down
14 changes: 10 additions & 4 deletions lib/util/removeIgnores.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ var fstreamIgnore = require('fstream-ignore');
var mout = require('mout');
var Q = require('q');

function removeIgnores(dir, ignore) {
function removeIgnores(dir, meta) {
var reader;
var applyIgnores;
var deferred = Q.defer();
var ignored = [];
var nonIgnored = [];
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(ignore);
reader.addIgnoreRules(['!bower.json']);
reader.addIgnoreRules(meta.ignore);

// Monkey patch applyIgnores such that we get hold of all ignored files
applyIgnores = reader.applyIgnores;
Expand Down
4 changes: 3 additions & 1 deletion test/core/resolvers/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ describe('Resolver', function () {
.done();
});

it('should remove files that match the ignore patterns', function (next) {
it('should remove files that match the ignore patterns excluding main files', function (next) {
var resolver = create({ source: 'foo', name: 'foo' });

mkdirp.sync(tempDir);
Expand All @@ -701,6 +701,8 @@ describe('Resolver', function () {
expect(fs.existsSync(path.join(tempDir, 'foo'))).to.be(true);
expect(fs.existsSync(path.join(tempDir, 'baz'))).to.be(true);
expect(fs.existsSync(path.join(tempDir, 'test'))).to.be(false);
expect(fs.existsSync(path.join(tempDir, 'bower.json'))).to.be(true);
expect(fs.existsSync(path.join(tempDir, 'main.js'))).to.be(true);
expect(fs.existsSync(path.join(tempDir, 'more/docs'))).to.be(false);
expect(fs.existsSync(path.join(tempDir, 'more/assets'))).to.be(false);
next();
Expand Down
4 changes: 4 additions & 0 deletions test/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@
"bar": "bar",
"baz": "baz",
"more/more-foo": "more-foo",
"main.js": "should not be ignored",
"more/docs/doc.html": "doc",
"more/assets/styles.css": "css",
"bower.json": {
"name": "a",
"version": "0.2.2",
"main": "main.js",
"ignore": [
"bower.json",
"main.js",
"test/",
"more/docs",
"more/assets/",
Expand Down

0 comments on commit b8df184

Please sign in to comment.