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);
|
const fileCode = fileData.slice(fileData.search(/```\s*js/i), fileData.lastIndexOf('```') + 3);
|
||||||
// Split code based on code markers
|
// Split code based on code markers
|
||||||
const blockMarkers = fileCode
|
const blockMarkers = fileCode
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map((line, lineIndex) => (line.slice(0, 3) === '```' ? lineIndex : '//CLEAR//'))
|
.map((line, lineIndex) => (line.slice(0, 3) === '```' ? lineIndex : '//CLEAR//'))
|
||||||
.filter(x => !(x === '//CLEAR//'));
|
.filter(x => !(x === '//CLEAR//'));
|
||||||
// Grab snippet function based on code markers
|
// Grab snippet function based on code markers
|
||||||
const fileFunction = fileCode
|
const fileFunction = fileCode
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(line => line.trim())
|
.map(line => line.trim())
|
||||||
.filter((_, i) => blockMarkers[0] < i && i < blockMarkers[1]);
|
.filter((_, i) => blockMarkers[0] < i && i < blockMarkers[1]);
|
||||||
// Grab snippet example based on code markers
|
// Grab snippet example based on code markers
|
||||||
const fileExample = fileCode
|
const fileExample = fileCode
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(line => line.trim())
|
.map(line => line.trim())
|
||||||
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
|
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
|
||||||
|
|
||||||
// Export template for snippetName.js
|
// Export template for snippetName.js
|
||||||
const exportFile = `${fileFunction.join('\n')}\n module.exports = ${fileName}`;
|
const exportFile = `${fileFunction.join('\n')}\n module.exports = ${fileName}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user