Skip to content

Commit

Permalink
fix(preprocessor): Directory names with dots
Browse files Browse the repository at this point in the history
Change minimatch call to match dirs with dots in the name while preprocessing.
Previously these files would be ignored by the preprocessor when matching.
  • Loading branch information
wied03 committed Nov 12, 2015
1 parent 50efbfb commit 4b5e094
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var createPreprocessor = function (config, basePath, injector) {
}

for (var i = 0; i < patterns.length; i++) {
if (mm(file.originalPath, patterns[i])) {
if (mm(file.originalPath, patterns[i], {dot: true})) {
if (thisFileIsBinary) {
log.warn('Ignoring preprocessing (%s) %s because it is a binary file.',
config[patterns[i]].join(', '), file.originalPath)
Expand Down
24 changes: 23 additions & 1 deletion test/unit/preprocessor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ describe('preprocessor', () => {
'b.js': mocks.fs.file(0, 'content'),
'a.txt': mocks.fs.file(0, 'some-text'),
'photo.png': mocks.fs.file(0, 'binary'),
'CAM_PHOTO.JPG': mocks.fs.file(0, 'binary')
'CAM_PHOTO.JPG': mocks.fs.file(0, 'binary'),
'.dir': {
'a.js': mocks.fs.file(0, 'content')
}
}
})

Expand Down Expand Up @@ -44,6 +47,25 @@ describe('preprocessor', () => {
})
})

it('should match directories starting with a dot', done => {
var fakePreprocessor = sinon.spy((content, file, done) => {
file.path = file.path + '-preprocessed'
done(null, 'new-content')
})

var injector = new di.Injector([{'preprocessor:fake': ['factory', () => fakePreprocessor]}])
pp = m.createPreprocessor({'**/*.js': ['fake']}, null, injector)

var file = {originalPath: '/some/.dir/a.js', path: 'path'}

pp(file, () => {
expect(fakePreprocessor).to.have.been.called
expect(file.path).to.equal('path-preprocessed')
expect(file.content).to.equal('new-content')
done()
})
})

it('should check patterns after creation when invoked', done => {
var fakePreprocessor = sinon.spy((content, file, done) => {
file.path = file.path + '-preprocessed'
Expand Down

0 comments on commit 4b5e094

Please sign in to comment.