From 21806687e696a1220995959c96e12e4fdc631b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Fri, 8 Apr 2016 15:23:46 +0200 Subject: [PATCH 1/2] Add base tests for fiailng ignore --- test/all.js | 1 + test/ignore.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/ignore.js diff --git a/test/all.js b/test/all.js index cb4e6051c..00046b582 100644 --- a/test/all.js +++ b/test/all.js @@ -19,6 +19,7 @@ require('./git'); require('./plugins'); require('./template'); require('./conrefs'); +require('./ignore'); // Page and HTML generation require('./page'); diff --git a/test/ignore.js b/test/ignore.js new file mode 100644 index 000000000..e8d833c1e --- /dev/null +++ b/test/ignore.js @@ -0,0 +1,33 @@ +var mock = require('./mock'); +var WebsiteOutput = require('../lib/output/website'); + +describe('Ignore', function() { + var output; + + before(function() { + return mock.outputDefaultBook(WebsiteOutput, { + '.ignore': 'test-1.js', + '.gitignore': 'test-2.js\ntest-3.js', + '.bookignore': '!test-3.js', + 'test-1.js': '1', + 'test-2.js': '2', + 'test-3.js': '3' + }) + .then(function(_output) { + output = _output; + }); + }); + + it('should load rules from .ignore', function() { + output.should.not.have.file('test-1.js'); + }); + + it('should load rules from .gitignore', function() { + output.should.not.have.file('test-2.js'); + }); + + it('should load rules from .bookignore', function() { + output.should.have.file('test-3.js'); + }); +}); + From 32a49a6969ad57cb8cc8a28c2b1db8c6779c653d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Fri, 8 Apr 2016 15:46:46 +0200 Subject: [PATCH 2/2] Inherit ignore rules of output from book --- lib/output/base.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/output/base.js b/lib/output/base.js index b60edb16b..4563646f7 100644 --- a/lib/output/base.js +++ b/lib/output/base.js @@ -37,6 +37,11 @@ function Output(book, opts, parent) { // Files to ignore in output this.ignore = Ignore(); + + // Hack to inherits from rules of the book: + // Waiting for https://github.com/kaelzhang/node-ignore/pull/19 to be merged + this.ignore._rules = this.ignore._rules.concat(this.book.ignore._rules); + this.ignore._cache = {}; } // Default name for generator