Pibd-21_Ievlewa_M.D._Intern.../node_modules/shebang-command/index.js

20 lines
387 B
JavaScript
Raw Normal View History

2023-12-03 19:52:09 +04:00
'use strict';
2023-12-22 00:41:43 +04:00
const shebangRegex = require('shebang-regex');
2023-12-03 19:52:09 +04:00
2023-12-22 00:41:43 +04:00
module.exports = (string = '') => {
const match = string.match(shebangRegex);
2023-12-03 19:52:09 +04:00
if (!match) {
return null;
}
2023-12-22 00:41:43 +04:00
const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
const binary = path.split('/').pop();
2023-12-03 19:52:09 +04:00
2023-12-22 00:41:43 +04:00
if (binary === 'env') {
return argument;
}
return argument ? `${binary} ${argument}` : binary;
2023-12-03 19:52:09 +04:00
};