(filename)
| 18 | * @returns {string | undefined} |
| 19 | */ |
| 20 | const findTsVersion = (filename) => { |
| 21 | try { |
| 22 | const data = fs.readFileSync(filename, "utf8"); |
| 23 | const lines = data.split("\n").map((line) => line.trim()); |
| 24 | const typescriptLineIndex = lines.findIndex((line) => FIRST_TYPESCRIPT_LINE.test(line)); |
| 25 | const matched = lines[typescriptLineIndex + 1].match(TYPESCRIPT_VERSION_LINE); |
| 26 | if (matched !== null) { |
| 27 | return matched[1]; |
| 28 | } |
| 29 | return undefined; |
| 30 | } catch { |
| 31 | return undefined; |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | module.exports = { findTsVersion }; |
no outgoing calls
no test coverage detected
searching dependent graphs…