(text, sectionName)
| 30 | } |
| 31 | |
| 32 | function getTomlSection(text, sectionName) { |
| 33 | const escapedSection = escapeRegExp(sectionName); |
| 34 | const headerPattern = new RegExp(`^\\s*\\[${escapedSection}\\]\\s*$`, 'm'); |
| 35 | const headerMatch = headerPattern.exec(text); |
| 36 | |
| 37 | assert.ok(headerMatch, `Expected TOML section to exist: [${sectionName}]`); |
| 38 | |
| 39 | const afterHeader = text.slice(headerMatch.index + headerMatch[0].length); |
| 40 | const nextHeaderIndex = afterHeader.search(/^\s*\[/m); |
| 41 | return nextHeaderIndex === -1 ? afterHeader : afterHeader.slice(0, nextHeaderIndex); |
| 42 | } |
| 43 | |
| 44 | let passed = 0; |
| 45 | let failed = 0; |
no test coverage detected