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

Support for binary files #42

Merged
merged 12 commits into from
Oct 23, 2018
Merged

Conversation

AndyBitz
Copy link
Contributor

This solves the same problem as #38 but includes both, CachedSource.js and Source.js.
It also adds a test for binary files.

PS: Fixes a linting error in ReplaceSource.js.

Fixes gajus/write-file-webpack-plugin#21

@jsf-clabot
Copy link

jsf-clabot commented Sep 26, 2018

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@alexander-akait alexander-akait left a 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
Copy link

codecov bot commented Sep 26, 2018

Codecov Report

Merging #42 into master will increase coverage by 3.35%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/CachedSource.js 46.34% <100%> (+41.34%) ⬆️
lib/Source.js 31.57% <100%> (+3.8%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f99964...a366b80. Read the comment docs.

@AndyBitz
Copy link
Contributor Author

Travis tells me to add the space and my local version tells me to remove it 🤔

@alexander-akait
Copy link
Member

@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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- new Buffer
+ Buffer.from

Copy link
Contributor Author

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

Copy link
Contributor Author

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- new Buffer
+ Buffer.from

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndyBitz Thx

@jeffrafter
Copy link

@michael-ciniawsky any chance this could merged now that it has been approved?

@AndyBitz
Copy link
Contributor Author

I guess @sokra and @ooflorent still need to review it?

@alexander-akait
Copy link
Member

/cc @sokra @ooflorent

@sokra sokra merged commit 1f11ae4 into webpack:master Oct 23, 2018
@sokra
Copy link
Member

sokra commented Oct 23, 2018

Thanks

@AndyBitz AndyBitz deleted the support-for-binary-files branch October 23, 2018 15:19
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.

6 participants