3 const fs = require('fs');
4 const shebangCommand = require('shebang-command');
6 function readShebang(command) {
7 // Read the first 150 bytes from the file
9 const buffer = Buffer.alloc(size);
14 fd = fs.openSync(command, 'r');
15 fs.readSync(fd, buffer, 0, size, 0);
17 } catch (e) { /* Empty */ }
19 // Attempt to extract shebang (null is returned if not a shebang)
20 return shebangCommand(buffer.toString());
23 module.exports = readShebang;