Skip to content

Commit 4b5e094

Browse files
committed
fix(preprocessor): Directory names with dots
Change minimatch call to match dirs with dots in the name while preprocessing. Previously these files would be ignored by the preprocessor when matching.
1 parent 50efbfb commit 4b5e094

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

lib/preprocessor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var createPreprocessor = function (config, basePath, injector) {
7474
}
7575

7676
for (var i = 0; i < patterns.length; i++) {
77-
if (mm(file.originalPath, patterns[i])) {
77+
if (mm(file.originalPath, patterns[i], {dot: true})) {
7878
if (thisFileIsBinary) {
7979
log.warn('Ignoring preprocessing (%s) %s because it is a binary file.',
8080
config[patterns[i]].join(', '), file.originalPath)

test/unit/preprocessor.spec.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ describe('preprocessor', () => {
1313
'b.js': mocks.fs.file(0, 'content'),
1414
'a.txt': mocks.fs.file(0, 'some-text'),
1515
'photo.png': mocks.fs.file(0, 'binary'),
16-
'CAM_PHOTO.JPG': mocks.fs.file(0, 'binary')
16+
'CAM_PHOTO.JPG': mocks.fs.file(0, 'binary'),
17+
'.dir': {
18+
'a.js': mocks.fs.file(0, 'content')
19+
}
1720
}
1821
})
1922

@@ -44,6 +47,25 @@ describe('preprocessor', () => {
4447
})
4548
})
4649

50+
it('should match directories starting with a dot', done => {
51+
var fakePreprocessor = sinon.spy((content, file, done) => {
52+
file.path = file.path + '-preprocessed'
53+
done(null, 'new-content')
54+
})
55+
56+
var injector = new di.Injector([{'preprocessor:fake': ['factory', () => fakePreprocessor]}])
57+
pp = m.createPreprocessor({'**/*.js': ['fake']}, null, injector)
58+
59+
var file = {originalPath: '/some/.dir/a.js', path: 'path'}
60+
61+
pp(file, () => {
62+
expect(fakePreprocessor).to.have.been.called
63+
expect(file.path).to.equal('path-preprocessed')
64+
expect(file.content).to.equal('new-content')
65+
done()
66+
})
67+
})
68+
4769
it('should check patterns after creation when invoked', done => {
4870
var fakePreprocessor = sinon.spy((content, file, done) => {
4971
file.path = file.path + '-preprocessed'

0 commit comments

Comments
 (0)