index.js 346 B

12345678910111213141516171819
  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. };