Merge pull request #563 from Chalarangelo/tdd-update
update tdd script tabbing chained methods making more readable
This commit is contained in:
@ -46,19 +46,19 @@ snippetFiles
|
||||
const fileCode = fileData.slice(fileData.search(/```\s*js/i), fileData.lastIndexOf('```') + 3);
|
||||
// Split code based on code markers
|
||||
const blockMarkers = fileCode
|
||||
.split('\n')
|
||||
.map((line, lineIndex) => (line.slice(0, 3) === '```' ? lineIndex : '//CLEAR//'))
|
||||
.filter(x => !(x === '//CLEAR//'));
|
||||
.split('\n')
|
||||
.map((line, lineIndex) => (line.slice(0, 3) === '```' ? lineIndex : '//CLEAR//'))
|
||||
.filter(x => !(x === '//CLEAR//'));
|
||||
// Grab snippet function based on code markers
|
||||
const fileFunction = fileCode
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.filter((_, i) => blockMarkers[0] < i && i < blockMarkers[1]);
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.filter((_, i) => blockMarkers[0] < i && i < blockMarkers[1]);
|
||||
// Grab snippet example based on code markers
|
||||
const fileExample = fileCode
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
|
||||
|
||||
// Export template for snippetName.js
|
||||
const exportFile = `${fileFunction.join('\n')}\n module.exports = ${fileName}`;
|
||||
|
||||
Reference in New Issue
Block a user