generator-begcode
Version:
Spring Boot + Angular/React/Vue in one handy generator
26 lines (25 loc) • 944 B
JavaScript
import { transform } from 'p-transform';
import TemplateFileFs from './template-file-fs.js';
export const createMultiStepTransform = () => {
const templateFileFs = new TemplateFileFs({});
const templateFiles = [];
const duplex = transform((file) => {
if (!templateFileFs.isTemplate(file.path)) {
throw new Error(`File ${file.path} is not supported`);
}
const templateFile = templateFileFs.add(file);
if (templateFile.rootTemplate) {
templateFiles.push(templateFile);
}
return undefined;
}, async function () {
for (const templateFile of templateFiles) {
const file = templateFile.file;
file.path = templateFile.basePath;
file.contents = Buffer.from(templateFile.render().concat('\n'));
this.push(templateFile.file);
}
});
duplex.templateFileFs = templateFileFs;
return duplex;
};