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-3/

Script File Validator

A tool that validates script files to ensure they have properly placed shebang lines at the beginning of the file.

Capabilities

Validates shebang position

  • Given a script file with a shebang at the very beginning, it returns true @test
  • Given a script file with whitespace before the shebang, it returns false @test
  • Given a script file with the shebang on the second line, it returns false @test
  • Given a file with no shebang at all, it returns false @test

Implementation

@generates

The implementation should export a function isValidShebang that takes a string (representing the content of a script file) and returns a boolean indicating whether the file has a properly positioned shebang line.

A properly positioned shebang line must:

  • Begin at the very start of the file (no leading whitespace or other characters)
  • Start with the #! character sequence

API

/**
 * Validates whether a script file has a properly positioned shebang line.
 *
 * @param {string} content - The content of the script file to validate.
 * @returns {boolean} True if the file has a valid shebang at the beginning, false otherwise.
 */
function isValidShebang(content) {
  // IMPLEMENTATION HERE
}

module.exports = { isValidShebang };

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