Skip to content

Commit 270333f

Browse files
committed
Recursion
1 parent ef2604d commit 270333f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/cli.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ async function generateProject(
282282
postProcessOptions,
283283
);
284284

285-
await writeFile(join(targetDir, filePath), content);
285+
const fullPath = join(targetDir, filePath);
286+
const {dirname} = await import('path');
287+
await mkdir(dirname(fullPath), {recursive: true});
288+
await writeFile(fullPath, content);
286289
}
287290
}

src/templateEngine.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,21 @@ export class TemplateEngine {
6565
return new Handlebars.SafeString(result + '\n');
6666
});
6767

68+
this.handlebars.registerHelper('eq', (a: any, b: any) => {
69+
return a === b;
70+
});
71+
6872
this.handlebars.registerHelper('includeFile', (options: any) => {
6973
if (!this.currentFile) return '';
7074

71-
const template = options.hash.template || '';
75+
const templatePath = options.hash.template || '';
7276
const outputTemplate = options.hash.output || '';
7377
const prettier = options.hash.prettier;
7478
const transpile = options.hash.transpile;
7579

76-
if (template && outputTemplate) {
77-
// Process the output path as a template
80+
if (templatePath && outputTemplate) {
81+
// Process both the template path and output path as templates
82+
const template = this.handlebars.compile(templatePath)(this.context);
7883
const output = this.handlebars.compile(outputTemplate)(this.context);
7984

8085
this.currentFile.includedFiles.push({

0 commit comments

Comments
 (0)