-
Notifications
You must be signed in to change notification settings - Fork 775
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
Use Buffer.alloc() instead of deprecated new Buffer() in copy-file-sync #380
Conversation
Why coverage decreased by -5.9%?!! 😳. The only thing that is changed is just a word! Edit IDK, maybe related to lemurheavy/coveralls-public#463. |
Great idea! The |
@jprichardson Wasn't aware of that. Isn't that a breaking change? |
Not strictly - it's more or less tightening the rules, as fs-extra still supports Node v4. Just not pre v4.5.0 - to be extra safe, I'm okay if we do another major bump but may not be necessary. |
…nc, add engines field to package.json to specify min node v4.5.0
6bff133
to
5597bd5
Compare
I rebased this on top of |
Thanks @manidlou! |
My pleasure 😄! |
Hello @manidlou , I guess I'm nine days late... But why don't we keep backward compatibility and use |
@dr-dimitru Actually, this change was reverted as a hotfix for v2.1.1. I'm thinking about some kind of fallback solution for future releases. |
Hi @RyanZim , Thank you, good to know. And I'm better to read CHANGELOG more carefully. This is how we use it on our packages (for if (typeof Buffer.from === 'function') {
try {
// Node 4.4.* Buffer.from already exists, but throws error
buff = Buffer.from(body, 'base64');
} catch (_error) {
buff = new Buffer(body, 'base64');
}
} else {
buff = new Buffer(body, 'base64');
} I can send a PR if you don't mind and agree with suggested code |
Sorry, I've been so busy. I also agree with providing some kind of fallback solution for this. |
@dr-dimitru I also fixed Thanks for telling me about I'm gonna try to open an issue later tonight to get some insight/discussion on this. |
@RyanZim Thank you, keep me updated. The code-sample above is just an example, same applies to |
Since
new Buffer()
is deprecated, https://nodejs.org/api/buffer.html#buffer_new_buffer_size, I updatedlib/copy-sync/copy-file-sync.js
to useBuffer.alloc()
instead of deprecatednew Buffer()
.