Skip to content

Commit 7d5a7da

Browse files
authored
Merge pull request #11 from code4rena-dev/fix/mustache-partials
feat: allow ci files to be partials so they can be extended
2 parents 02f4295 + 643ec6b commit 7d5a7da

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default async function (root: string, variables: Variables) {
9898
"scripts/clean.ts": copy(join(__dirname, "content", "clean.ts")),
9999
".github/workflows/ci.yml": mustache({
100100
sourcePath: join(__dirname, "content", "ci.yml"),
101-
variables,
101+
variables: variables.ci,
102102
}),
103103
".github/matchers/tap.json": copy(join(__dirname, "content", "tap.json")),
104104
};

lib/mustache.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Generator } from "code-skeleton/lib/generators/abstract";
1+
import { Generator, ValidateInput } from "code-skeleton/lib/generators/abstract";
2+
import { GeneratorReportResult } from "code-skeleton/lib/generators/report";
23
import { readFile } from "node:fs/promises";
34
import Mustache from "mustache";
45
Mustache.tags = [ "<%", "%>" ];
@@ -25,6 +26,20 @@ class MustacheGenerator extends Generator<MustacheGeneratorOptions> {
2526
const rendered = Mustache.render(source.toString(), this.options.variables);
2627
return rendered;
2728
}
29+
30+
async validate(options: ValidateInput) : Promise<GeneratorReportResult> {
31+
const expected = await this.generate();
32+
33+
if (!options.found.includes(expected)) {
34+
this.report({
35+
expected,
36+
found: options.found,
37+
message: `${this.options.sourcePath} does not include the original template`
38+
});
39+
return GeneratorReportResult.Fail;
40+
}
41+
return GeneratorReportResult.Pass;
42+
}
2843
}
2944

3045
export function mustache (options: MustacheGeneratorOptions) {

0 commit comments

Comments
 (0)