( content: string, pattern: string, )
| 123 | } |
| 124 | |
| 125 | export 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 | |
| 135 | export function filePathToCliArg(filePath: string): string { |
| 136 | // needs to be escaped if spaces included |
no outgoing calls
no test coverage detected