github-pages-deploy-action/node_modules/shebang-command/index.js

20 lines
387 B
JavaScript
Raw Normal View History

2020-01-28 13:07:56 +08:00
'use strict';
2020-05-15 05:33:08 +08:00
const shebangRegex = require('shebang-regex');
2020-01-28 13:07:56 +08:00
2020-05-15 05:33:08 +08:00
module.exports = (string = '') => {
const match = string.match(shebangRegex);
2020-01-28 13:07:56 +08:00
if (!match) {
return null;
}
2020-05-15 05:33:08 +08:00
const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
const binary = path.split('/').pop();
2020-01-28 13:07:56 +08:00
2020-05-15 05:33:08 +08:00
if (binary === 'env') {
return argument;
}
return argument ? `${binary} ${argument}` : binary;
2020-01-28 13:07:56 +08:00
};