How to use the shebang-regex.test function in shebang-regex

To help you get started, we’ve selected a few shebang-regex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stevemao / mock-bin / index.js View on Github external
module.exports = (bin, shebang, code) => {
	if (!shebangRegex.test(shebang)) {
		shebang = '#!/usr/bin/env ' + shebang;
	}

	// On windows shebangs aren't supported. Use a fake extension to prevent
	// the bin from being executed instead of the shim.
	const fileName = bin + (process.platform === 'win32' ? '.x-mock-bin' : '');

	let oldPath = shell.env.PATH;

	return tempWrite(shebang + '\n' + code, fileName)
		.then(filepath => {
			// Path separator according to platform
			const sep = process.platform === 'win32' ? ';' : ':';
			shell.chmod('+x', filepath);
			shell.env.PATH = filepath.replace(new RegExp(fileName + '$'), '') + sep + oldPath;

shebang-regex

Regular expression for matching a shebang line

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular shebang-regex functions