(source, startIndex, openChar, closeChar)
| 15 | const buildSource = await fs.readFile(buildScriptPath, 'utf8') |
| 16 | |
| 17 | function findMatchingDelimiter(source, startIndex, openChar, closeChar) { |
| 18 | let depth = 0 |
| 19 | let quote = null |
| 20 | let inLineComment = false |
| 21 | let inBlockComment = false |
| 22 | const templateResumeDepths = [] |
| 23 | |
| 24 | for (let i = startIndex; i < source.length; i += 1) { |
| 25 | const char = source[i] |
| 26 | const next = source[i + 1] |
| 27 | |
| 28 | if (inLineComment) { |
| 29 | if (char === '\n') inLineComment = false |
| 30 | continue |
| 31 | } |
| 32 | |
| 33 | if (inBlockComment) { |
| 34 | if (char === '*' && next === '/') { |
| 35 | inBlockComment = false |
| 36 | i += 1 |
| 37 | } |
| 38 | continue |
| 39 | } |
| 40 | |
| 41 | if (quote) { |
| 42 | if (quote === '`' && char === '$' && next === '{') { |
| 43 | if (openChar === '{') depth += 1 |
| 44 | templateResumeDepths.push(depth) |
| 45 | quote = null |
| 46 | i += 1 |
| 47 | continue |
| 48 | } |
| 49 | if (char === '\\') { |
| 50 | i += 1 |
| 51 | continue |
| 52 | } |
| 53 | if (char === quote) { |
| 54 | quote = null |
| 55 | } |
| 56 | continue |
| 57 | } |
| 58 | |
| 59 | if (char === '/' && next === '/') { |
| 60 | inLineComment = true |
| 61 | i += 1 |
| 62 | continue |
| 63 | } |
| 64 | |
| 65 | if (char === '/' && next === '*') { |
| 66 | inBlockComment = true |
| 67 | i += 1 |
| 68 | continue |
| 69 | } |
| 70 | |
| 71 | if (char === "'" || char === '"' || char === '`') { |
| 72 | quote = char |
| 73 | continue |
| 74 | } |
no outgoing calls
no test coverage detected