git.iko.soy/rowtype-yoga/yoga-r3f
on main help sign in
19 lines 387 B history raw
1'use strict';
2const shebangRegex = require('shebang-regex');
4module.exports = (string = '') => {
5 const match = string.match(shebangRegex);
7 if (!match) {
8 return null;
9 }
11 const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
12 const binary = path.split('/').pop();
14 if (binary === 'env') {
15 return argument;
16 }
18 return argument ? `${binary} ${argument}` : binary;
19};