Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid using deprecated Buffer constructor (#94)
* fix: avoid using deprecated Buffer constructor Buffer.alloc() is supported on Node.js >= 4.5.0, and allocates a zero-filled buffer on all supported versions. This solves two issues: * Buffer() constructor (aka 'new Buffer()') is deprecated, so avoid using it * On 4.x and 6.x, Buffer(number) is not zero-filled, so this code was allocating an uninitialized Buffer when file length was less than 150, so the behaviour of readShebang() was actually undefined in that case (as in could have returned anything, depending on the uninitialized memory chunk). Refs: https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor * readShebang: name reused inline constant '150' was used two times, it deserves a name. It's the size of the pre-read buffer. * readShebang: Buffer API compat for old Node.js To be reverted when dropping outdated Node.js versions support.
- Loading branch information