-
Notifications
You must be signed in to change notification settings - Fork 71
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
Support for binary files #42
Conversation
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 fix tests
Codecov Report
@@ Coverage Diff @@
## master #42 +/- ##
==========================================
+ Coverage 74.89% 78.25% +3.35%
==========================================
Files 11 11
Lines 490 492 +2
Branches 74 76 +2
==========================================
+ Hits 367 385 +18
+ Misses 123 107 -16
Continue to review full report at Codecov.
|
Travis tells me to add the space and my local version tells me to remove it 🤔 |
@AndyBitz Looks we need more tests 👍 |
if(typeof this._cachedSource !== "undefined") | ||
return this._cachedSize = this._cachedSource.length; | ||
if(typeof this._cachedSource !== "undefined") { | ||
if(Buffer.from.length === 1) return new Buffer(this._cachedSource).length; |
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.
- new Buffer
+ Buffer.from
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.
Tried that, but that causes the tests to fail for pre node 5.10. Buffer.from.length
checks if it supports Buffer.from
and if it is equal to 1, it doesn't
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.
And if it is after 5.10, it supports Buffer.byteLength
.
@@ -14,7 +14,8 @@ class Source { | |||
} | |||
|
|||
size() { | |||
return this.source().length; | |||
if(Buffer.from.length === 1) return new Buffer(this.source()).length; |
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.
- new Buffer
+ Buffer.from
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.
@AndyBitz Thx
@michael-ciniawsky any chance this could merged now that it has been approved? |
I guess @sokra and @ooflorent still need to review it? |
/cc @sokra @ooflorent |
Thanks |
This solves the same problem as #38 but includes both,
CachedSource.js
andSource.js
.It also adds a test for binary files.
PS: Fixes a linting error in
ReplaceSource.js
.Fixes gajus/write-file-webpack-plugin#21