Skip to content

Commit 1688689

Browse files
committed
feat(preprocessor): Capital letters in binary files extenstions
Use lower case file extension to detect if it is binary Closes #1508
1 parent 57bf9e3 commit 1688689

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/preprocessor.js

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

4848
return function preprocess (file, done) {
4949
patterns = Object.keys(config)
50-
var thisFileIsBinary = isBinary[path.extname(file.originalPath)]
50+
var thisFileIsBinary = isBinary[path.extname(file.originalPath).toLowerCase()]
5151
var preprocessors = []
5252

5353
var nextPreprocessor = function (error, content) {

test/unit/preprocessor.spec.coffee

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe 'preprocessor', ->
1414
'b.js': mocks.fs.file 0, 'content'
1515
'a.txt': mocks.fs.file 0, 'some-text'
1616
'photo.png': mocks.fs.file 0, 'binary'
17+
'CAM_PHOTO.JPG': mocks.fs.file 0, 'binary'
1718

1819
mocks_ =
1920
'graceful-fs': mockFs
@@ -195,3 +196,21 @@ describe 'preprocessor', ->
195196
expect(fakePreprocessor).not.to.have.been.called
196197
expect(file.content).to.be.an.instanceof Buffer
197198
done()
199+
200+
201+
it 'should not preprocess binary files with capital letters in extension', (done) ->
202+
fakePreprocessor = sinon.spy (content, file, done) ->
203+
done null, content
204+
205+
injector = new di.Injector [{
206+
'preprocessor:fake': ['factory', -> fakePreprocessor]
207+
}]
208+
209+
pp = m.createPreprocessor {'**/*': ['fake']}, null, injector
210+
211+
file = {originalPath: '/some/CAM_PHOTO.JPG', path: 'path'}
212+
213+
pp file, (err) ->
214+
expect(fakePreprocessor).not.to.have.been.called
215+
expect(file.content).to.be.an.instanceof Buffer
216+
done()

0 commit comments

Comments
 (0)