Urara-Blog/node_modules/.pnpm-store/v3/files/45/877768d4aac0233bef65c32cbb8cb0d37151a23428f717444b2c2b71b39f1b062522d6ff8a3dc4432e3f63df66a55ae72957ec5525c89ce10278775f862bcb
2022-08-14 01:14:53 +08:00

23 lines
549 B
Text

'use strict';
const fs = require('fs');
const shebangCommand = require('shebang-command');
function readShebang(command) {
// Read the first 150 bytes from the file
const size = 150;
const buffer = Buffer.alloc(size);
let fd;
try {
fd = fs.openSync(command, 'r');
fs.readSync(fd, buffer, 0, size, 0);
fs.closeSync(fd);
} catch (e) { /* Empty */ }
// Attempt to extract shebang (null is returned if not a shebang)
return shebangCommand(buffer.toString());
}
module.exports = readShebang;