|
1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
-
- const fs = require('fs');
- const shebangCommand = require('shebang-command');
-
- function readShebang(command) {
-
- const size = 150;
- let buffer;
-
- if (Buffer.alloc) {
-
- buffer = Buffer.alloc(size);
- } else {
-
- buffer = new Buffer(size);
- buffer.fill(0);
- }
-
- let fd;
-
- try {
- fd = fs.openSync(command, 'r');
- fs.readSync(fd, buffer, 0, size, 0);
- fs.closeSync(fd);
- } catch (e) { }
-
-
- return shebangCommand(buffer.toString());
- }
-
- module.exports = readShebang;
|