MCPcopy Create free account
hub / github.com/breck7/scroll / buildFiles

Method buildFiles

scroll.js:175–202  ·  view source on GitHub ↗
(fileSystem, files, folder, options = {})

Source from the content-addressed store, hash-verified

173 }
174
175 async buildFiles(fileSystem, files, folder, options = {}) {
176 const start = Date.now()
177 // Run the build loop twice. The first time we build ScrollSets, in case some of the HTML files
178 // will depend on csv/tsv/json/etc
179 const toBuild = files.filter(file => !file.scrollProgram.importOnly)
180 options.externalFilesCopied = {}
181 for (const file of toBuild) {
182 file.scrollProgram.logger = this
183 await file.scrollProgram.load()
184 }
185 for (const file of toBuild) {
186 await file.scrollProgram.buildOne(options)
187 }
188 for (const file of toBuild) {
189 await file.scrollProgram.buildTwo(options)
190 }
191 const seconds = (Date.now() - start) / 1000
192 this.log(``)
193 const outputExtensions = fileSystem.productCache.map(filename => filename.split(".").pop())
194 const buildStats = lodash.map(lodash.orderBy(lodash.toPairs(lodash.countBy(outputExtensions)), 1, "desc"), ([extension, count]) => ({ extension, count }))
195 this.log(
196 `⌛️ Read ${files.length} scroll files and wrote ${fileSystem.productCache.length} files (${buildStats.map(i => i.extension + ":" + i.count).join(" ")}) in ${seconds} seconds. Processed ${lodash.round(
197 files.length / seconds
198 )} scroll files per second\n`
199 )
200
201 return fileSystem.productCache
202 }
203
204 async buildFilesInFolder(folder = "/", fileSystem = this.sfs) {
205 folder = ensureFolderEndsInSlash(folder)

Callers 2

buildCommandMethod · 0.95
buildFilesInFolderMethod · 0.95

Calls 6

loadMethod · 0.80
logMethod · 0.80
mapMethod · 0.80
splitMethod · 0.80
filterMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected