Regular expression for matching Unix shebang lines at the beginning of files
88
A utility that validates whether script files contain proper shebang lines. This tool is useful for ensuring that executable scripts have the correct interpreter directives at the beginning of their files.
true if the content begins with a valid shebang line, and false otherwise @testfalse for content that does not start with a shebang line @testfalse for content with a shebang line not at the beginning @testname and content properties), returns only those files that contain valid shebang lines at the beginning @test@generates
/**
* Validates whether script content begins with a valid shebang line.
*
* @param {string} content - The script content to validate.
* @returns {boolean} True if content begins with a shebang, false otherwise.
*/
function hasShebang(content) {
// IMPLEMENTATION HERE
}
/**
* Filters an array of script files to return only those with valid shebangs.
*
* @param {Array<{name: string, content: string}>} files - Array of file objects.
* @returns {Array<{name: string, content: string}>} Files with valid shebangs.
*/
function filterScriptsWithShebang(files) {
// IMPLEMENTATION HERE
}
module.exports = {
hasShebang,
filterScriptsWithShebang,
};Provides regular expression for matching Unix shebang lines.
Install with Tessl CLI
npx tessl i tessl/npm-shebang-regexdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9