xref: /third_party/node/deps/npm/node_modules/shebang-command/index.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/deps/npm/node_modules/shebang-command/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst shebangRegex = require('shebang-regex');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cimodule.exports = (string = '') => {
51cb0ef41Sopenharmony_ci	const match = string.match(shebangRegex);
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci	if (!match) {
81cb0ef41Sopenharmony_ci		return null;
91cb0ef41Sopenharmony_ci	}
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci	const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
121cb0ef41Sopenharmony_ci	const binary = path.split('/').pop();
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci	if (binary === 'env') {
151cb0ef41Sopenharmony_ci		return argument;
161cb0ef41Sopenharmony_ci	}
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci	return argument ? `${binary} ${argument}` : binary;
191cb0ef41Sopenharmony_ci};
20

Indexes created Thu Nov 07 10:32:03 CST 2024