emerald-templates
Version:
Intelligent Template Generation & Project Management
41 lines (38 loc) • 1.24 kB
JavaScript
const processEmeraldLinks = require('./processEmeraldLinks')
const populateEmeralds = require('./populateEmeralds')
const processEmeraldScripts = require('./processEmeraldScripts')
const getEmeraldConfig = require('./getEmeraldConfig')
async function processOutputFolder(outputFolder, templateFolder, options = {}) {
if (typeof options != 'object' || options === null) options = {}
const projectConfig = await getEmeraldConfig(templateFolder)
let filesProcessed = 0
let firstRun = true
// Deeply recur, and process all files, even files generated by other emerald scripts
// TODO: add more circular processing protection? No idea how to do this
while (firstRun === true || filesProcessed > 0) {
filesProcessed = 0
filesProcessed += await processEmeraldLinks(
outputFolder,
templateFolder,
projectConfig,
firstRun,
options
)
filesProcessed += await populateEmeralds(
outputFolder,
templateFolder,
projectConfig,
firstRun,
options
)
filesProcessed += await processEmeraldScripts(
outputFolder,
templateFolder,
projectConfig,
firstRun,
options
)
firstRun = false
}
}
module.exports = processOutputFolder