Skip to content
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

Proposal: Allow preprocessor to handle binary files #3046

Closed
kyliau opened this issue Jun 15, 2018 · 1 comment
Closed

Proposal: Allow preprocessor to handle binary files #3046

kyliau opened this issue Jun 15, 2018 · 1 comment

Comments

@kyliau
Copy link
Collaborator

kyliau commented Jun 15, 2018

Karma currently detects whether a file is binary, and does not allow binary files to be passed on to preprocessors. The code is here and reproduced below.

if (thisFileIsBinary) {
  log.warn('Ignoring preprocessing (%s) %s because it is a binary file.',
    config[patterns[i]].join(', '), file.originalPath)
} else {
  preprocessorNames = combineLists(preprocessorNames, config[patterns[i]])
}

I'd like to propose that this restriction be removed, and allow binary files to be handled by preprocessors.

The main use case I have for this is to create a preprocessor that handles zip files containing Javascript code. In Google, due to the restriction of the build system, zip files are unavoidable, and it is not possible to extract them before running Karma. Relaxing this restriction would allow the creation of a preprocessor that handles this case.

To maintain backwards compatibility and prevent breakages, all plugins that handle binary files would
need to explicitly declare so. This can be done by adding a property handleBinaryFile = true to the
plugin. Without this flag, Karma will automatically fall back to the existing behavior - print a warning and ignore the file.

The actual code change is minimal, please see this PR.

@johnjbarton
Copy link
Contributor

Fixed by #3054, thanks @kyliau

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants