Regular expression for matching Unix shebang lines at the beginning of files
88
Build a utility that analyzes multiple script files and safely extracts interpreter information, handling files that may or may not contain shebang lines.
Your implementation should:
#! prefix) if a shebang existshasShebang: boolean indicating if a shebang was foundinterpreter: the interpreter path if found, or null if not found#!/usr/bin/env node\nconsole.log("test"), returns [{hasShebang: true, interpreter: "/usr/bin/env node"}] @testconsole.log("test"), returns [{hasShebang: false, interpreter: null}] @test#!/bin/bash\necho "hi", returns correct results for all three scripts @test@generates
/**
* Analyzes an array of script strings and extracts interpreter information.
*
* @param {string[]} scripts - Array of script content strings
* @returns {Array<{hasShebang: boolean, interpreter: string|null}>} Array of analysis results
*/
function analyzeScripts(scripts) {
// IMPLEMENTATION HERE
}
module.exports = { analyzeScripts };Provides regular expression for matching shebang lines
@satisfied-by
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