You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
346 B

4 years ago
  1. 'use strict';
  2. var shebangRegex = require('shebang-regex');
  3. module.exports = function (str) {
  4. var match = str.match(shebangRegex);
  5. if (!match) {
  6. return null;
  7. }
  8. var arr = match[0].replace(/#! ?/, '').split(' ');
  9. var bin = arr[0].split('/').pop();
  10. var arg = arr[1];
  11. return (bin === 'env' ?
  12. arg :
  13. bin + (arg ? ' ' + arg : '')
  14. );
  15. };