Regular expression for matching Unix shebang lines at the beginning of files
88
{
"context": "This criteria evaluates how effectively the engineer uses the shebang-regex package to parse shebang lines and extract interpreter information through regex capture group manipulation. The focus is on proper usage of the RegExp exec() method and accessing capture groups to retrieve both the full shebang line and the interpreter path.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Import shebang-regex",
"description": "Correctly imports the shebangRegex from the 'shebang-regex' package using ES module syntax",
"max_score": 10
},
{
"name": "Use exec() method",
"description": "Uses the shebangRegex.exec() method to match and extract shebang information from script content",
"max_score": 25
},
{
"name": "Access full shebang",
"description": "Correctly accesses capture group [0] from the exec() result to retrieve the complete shebang line including the #! prefix",
"max_score": 20
},
{
"name": "Access interpreter path",
"description": "Correctly accesses capture group [1] from the exec() result to retrieve the interpreter path without the #! prefix",
"max_score": 20
},
{
"name": "Handle null results",
"description": "Properly handles the case when exec() returns null (no shebang found) using null checks, optional chaining, or similar patterns",
"max_score": 15
},
{
"name": "Parse interpreter name",
"description": "Extracts the base interpreter name from the interpreter path by parsing the string (e.g., extracting 'node' from '/usr/bin/env node' or 'bash' from '/bin/bash')",
"max_score": 10
}
]
}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