CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-shebang-regex

Regular expression for matching Unix shebang lines at the beginning of files

88

1.54x
Overview
Eval results
Files

task.mdevals/scenario-2/

Script File Validator

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.

Capabilities

Validates single script content

  • Given a string containing script content, returns true if the content begins with a valid shebang line, and false otherwise @test
  • Returns false for content that does not start with a shebang line @test
  • Returns false for content with a shebang line not at the beginning @test

Filters script files by shebang presence

  • Given an array of script file objects (each with name and content properties), returns only those files that contain valid shebang lines at the beginning @test
  • Returns an empty array when no files have valid shebangs @test

Implementation

@generates

API

/**
 * 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,
};

Dependencies { .dependencies }

shebang-regex { .dependency }

Provides regular expression for matching Unix shebang lines.

Install with Tessl CLI

npx tessl i tessl/npm-shebang-regex

tile.json