版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

24 wiersze
549 B

  1. 'use strict';
  2. const fs = require('fs');
  3. const shebangCommand = require('shebang-command');
  4. function readShebang(command) {
  5. // Read the first 150 bytes from the file
  6. const size = 150;
  7. const buffer = Buffer.alloc(size);
  8. let fd;
  9. try {
  10. fd = fs.openSync(command, 'r');
  11. fs.readSync(fd, buffer, 0, size, 0);
  12. fs.closeSync(fd);
  13. } catch (e) { /* Empty */ }
  14. // Attempt to extract shebang (null is returned if not a shebang)
  15. return shebangCommand(buffer.toString());
  16. }
  17. module.exports = readShebang;