Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | const fs = require('fs'); const path = require('path'); const { arrayOfLines } = require('./helpers.js'); const TYPE_TOKENS = 'Tokens'; /** * parse * @returns {object} */ function parse() { const generalNotes = fs.readFileSync( path.resolve('design-tokens/RELEASENOTES.md'), { encoding: 'utf-8' } ); const reVersionLine = /^\##\s*(\d+\.\d+\.\d+)([\n]+)$/; const noteBlocks = generalNotes.replace( RegExp(reVersionLine, 'gm'), // Find any 2nd-level headings (e.g., ## TEXT) '___DELIMITER_A___$1___DELIMITER_VERSION_LINE___' ); const getVersionString = block => { return block.replace(/^(.+)___DELIMITER_VERSION_LINE___.+/, '$1'); }; const notes = noteBlocks // this splits the release notes into per-version segments .split('___DELIMITER_A___') // split by version block .splice(1) // ignore version line .map(perVerNotes => ({ // parse notes version: getVersionString( perVerNotes.split('___DELIMITER_VERSION_LINE___')[0] ), versionNotes: arrayOfLines( perVerNotes.split('___DELIMITER_VERSION_LINE___')[1] ) })); return { type: TYPE_TOKENS, notes }; } module.exports = { parse, TYPE_TOKENS }; |