MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / createChunks

Function createChunks

lib/command/run-multiple/chunk.js:64–90  ·  view source on GitHub ↗
(config, patterns = [])

Source from the content-addressed store, hash-verified

62 * the splitting.
63 */
64const createChunks = (config, patterns = []) => {
65 const files = patterns
66 .filter(pattern => !!pattern)
67 .map(pattern => {
68 return findFiles(pattern).filter(file => {
69 return config.grep ? grepFile(file, config.grep) : true
70 })
71 })
72 .reduce((acc, val) => acc.concat(val), [])
73
74 let chunks = []
75 if (typeof config.chunks === 'function') {
76 chunks = config.chunks.call(this, files)
77 } else if (typeof config.chunks === 'number' || typeof config.chunks === 'string') {
78 chunks = splitFiles(files, Math.ceil(files.length / config.chunks))
79 } else {
80 throw new Error('chunks is neither a finite number or a valid function')
81 }
82
83 const chunkConfig = { ...config }
84 delete chunkConfig.chunks
85
86 return chunks.map(chunkFiles => {
87 const { js, gherkin } = mapFileFormats(chunkFiles)
88 return { ...chunkConfig, tests: flattenFiles(js), gherkin: { features: flattenFiles(gherkin) } }
89 })
90}
91
92export {
93 createChunks

Callers 1

prepareChunksMethod · 0.90

Calls 6

findFilesFunction · 0.85
grepFileFunction · 0.85
splitFilesFunction · 0.85
mapFileFormatsFunction · 0.85
flattenFilesFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected