Skip to content

Conversation

jeroenpelgrims
Copy link

@jeroenpelgrims jeroenpelgrims commented Sep 14, 2018

Hey,

I couldn't get this transformation to work, I never got the window context applied so I did some digging.

The callback is being called immediately with the file's default contents, for every file.
When the callback is called: 1. the contents are written to the stream, and 2. null is being written to the stream. Effectively signalling that we're done writing to it.

The callback will be called again for files that need the transformation, but since the stream has already been marked as "ended" this will have no effect.

I changed the code so that the callback is only called once.

  • Either with the original contents of the file (if no transformation is needed)
  • Or with the transformed contents of the transformation is needed.

I can see on NPM this plugin is actually used by people (200 DLs/week) but I don't get how it has ever been able to work?

Will now only write to stream after it's been checked if we need to apply the window context or not.
@jeroenpelgrims jeroenpelgrims deleted the fix-transformation branch September 14, 2018 15:03
@jeroenpelgrims
Copy link
Author

jeroenpelgrims commented Sep 14, 2018

This doesn't fix the issue completely, this potentially calls the callback too often.
Edit: fixed in next commit.

@jeroenpelgrims jeroenpelgrims restored the fix-transformation branch September 14, 2018 15:49
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

Successfully merging this pull request may close these issues.

1 participant