-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(preprocessor): Allow preprocessor to handle binary files #3054
Conversation
@@ -125,7 +120,12 @@ function createPreprocessor (config, basePath, injector) { | |||
} | |||
|
|||
instances[name] = p | |||
preprocessors.push(p) | |||
if (!thisFileIsBinary || p.handleBinaryFiles) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need handleBinaryFiles
flag and this whole if statement ? Maybe we can just allow to preprocess binary files, and if something fails, preprocessor will throw error.
I guess in more than 90% there will be no binary files that matches pattern and should be preprocessed (Do I miss something ?).
Just thinking out loud, and I'm curious others opinion about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just for safe backwards compatibility.
Currently if there is a pattern foo/*
that matches binary files, it is ignored. Without this flag, the 10% projects that do include binary files in their pattern will break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test for this feature.
lib/preprocessor.js
Outdated
if (!thisFileIsBinary || p.handleBinaryFiles) { | ||
preprocessors.push(p) | ||
} else { | ||
log.warn('Ignoring preprocessing (%s) %s because it is a binary file.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this message could be clearer as
'Ignoring preprocessing %s because %s has handleBinaryFiles false.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Karma currently detects whether a file is binary, and does not allow binary files to be passed on to preprocessors. This PR removes this restriction, and allows binary files to be handled by preprocessors.
See #3046