MCPcopy Index your code
hub / github.com/code-pushup/cli / findLineNumberInText

Function findLineNumberInText

packages/utils/src/lib/file-system.ts:125–133  ·  view source on GitHub ↗
(
  content: string,
  pattern: string,
)

Source from the content-addressed store, hash-verified

123}
124
125export function findLineNumberInText(
126 content: string,
127 pattern: string,
128): number | null {
129 const lines = content.split(/\r?\n/); // Split lines, handle both Windows and UNIX line endings
130
131 const lineNumber = lines.findIndex(line => line.includes(pattern)) + 1; // +1 because line numbers are 1-based
132 return lineNumber === 0 ? null : lineNumber; // If the package isn't found, return null
133}
134
135export function filePathToCliArg(filePath: string): string {
136 // needs to be escaped if spaces included

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected