diff --git a/lib/util/readShebang.js b/lib/util/readShebang.js index be35dff..957dd70 100644 --- a/lib/util/readShebang.js +++ b/lib/util/readShebang.js @@ -5,12 +5,23 @@ const shebangCommand = require('shebang-command'); function readShebang(command) { // Read the first 150 bytes from the file + const size = 150; + + let buffer; + if (Buffer.alloc) { + // Node.js v4.5+ / v5.10+ + buffer = Buffer.alloc(size); + } else { + // Old Node.js API + buffer = new Buffer(size); + buffer.fill(0); // zero-fill + } + let fd; - const buffer = new Buffer(150); try { fd = fs.openSync(command, 'r'); - fs.readSync(fd, buffer, 0, 150, 0); + fs.readSync(fd, buffer, 0, size, 0); fs.closeSync(fd); } catch (e) { /* Empty */ }