• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const shebangRegex = require('shebang-regex');
3
4module.exports = (string = '') => {
5	const match = string.match(shebangRegex);
6
7	if (!match) {
8		return null;
9	}
10
11	const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
12	const binary = path.split('/').pop();
13
14	if (binary === 'env') {
15		return argument;
16	}
17
18	return argument ? `${binary} ${argument}` : binary;
19};
20