time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

index.js (387B)


      1 'use strict';
      2 const shebangRegex = require('shebang-regex');
      3 
      4 module.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 };