Skip to content

Commit

Permalink
feat(preprocessor): Capital letters in binary files extenstions
Browse files Browse the repository at this point in the history
Use lower case file extension to detect if it is binary

Closes #1508
  • Loading branch information
lonelyelk committed Jul 21, 2015
1 parent 57bf9e3 commit 1688689
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var createPreprocessor = function (config, basePath, injector) {

return function preprocess (file, done) {
patterns = Object.keys(config)
var thisFileIsBinary = isBinary[path.extname(file.originalPath)]
var thisFileIsBinary = isBinary[path.extname(file.originalPath).toLowerCase()]
var preprocessors = []

var nextPreprocessor = function (error, content) {
Expand Down
19 changes: 19 additions & 0 deletions test/unit/preprocessor.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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'

mocks_ =
'graceful-fs': mockFs
Expand Down Expand Up @@ -195,3 +196,21 @@ describe 'preprocessor', ->
expect(fakePreprocessor).not.to.have.been.called
expect(file.content).to.be.an.instanceof Buffer
done()


it 'should not preprocess binary files with capital letters in extension', (done) ->
fakePreprocessor = sinon.spy (content, file, done) ->
done null, content

injector = new di.Injector [{
'preprocessor:fake': ['factory', -> fakePreprocessor]
}]

pp = m.createPreprocessor {'**/*': ['fake']}, null, injector

file = {originalPath: '/some/CAM_PHOTO.JPG', path: 'path'}

pp file, (err) ->
expect(fakePreprocessor).not.to.have.been.called
expect(file.content).to.be.an.instanceof Buffer
done()

0 comments on commit 1688689

Please sign in to comment.