Pibd-21_Alekseev_I.S._Inter.../IP/node_modules/shebang-command/index.js

20 lines
387 B
JavaScript
Raw Normal View History

2023-12-03 16:59:28 +04:00
'use strict';
2024-01-06 20:33:49 +04:00
const shebangRegex = require('shebang-regex');
2023-12-03 16:59:28 +04:00
2024-01-06 20:33:49 +04:00
module.exports = (string = '') => {
const match = string.match(shebangRegex);
2023-12-03 16:59:28 +04:00
if (!match) {
return null;
}
2024-01-06 20:33:49 +04:00
const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
const binary = path.split('/').pop();
2023-12-03 16:59:28 +04:00
2024-01-06 20:33:49 +04:00
if (binary === 'env') {
return argument;
}
return argument ? `${binary} ${argument}` : binary;
2023-12-03 16:59:28 +04:00
};