MCPcopy Index your code
hub / github.com/nodejs/node / parseSection

Function parseSection

test/parallel/test-process-env-allowed-flags-are-documented.js:14–22  ·  view source on GitHub ↗
(text, startMarker, endMarker)

Source from the content-addressed store, hash-verified

12const cliText = fs.readFileSync(cliMd, { encoding: 'utf8' });
13
14const parseSection = (text, startMarker, endMarker) => {
15 const regExp = new RegExp(`${RegExp.escape(startMarker)}\r?\n([^]*)\r?\n${RegExp.escape(endMarker)}`);
16 const match = text.match(regExp);
17 if (!match)
18 assert.fail(`Unable to locate text between '${startMarker}' and '${endMarker}'.`);
19 return match[1]
20 .split(/\r?\n/)
21 .filter((val) => val.trim() !== '');
22};
23
24const nodeOptionsLines = parseSection(cliText,
25 '<!-- node-options-node start -->',

Calls 5

matchMethod · 0.65
filterMethod · 0.65
escapeMethod · 0.45
failMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…