Describe the bug
conditionalGeneration (and the deprecated conditionalFiles) keys are written with POSIX separators in a template's config, for example conditionalFolder2/input.txt. The lookups in apps/generator/lib/generator.js build their key with path.relative, which returns backslashes on Windows, so a nested key never matches and the condition is silently ignored.
Executed on win32:
path.relative gives : "conditionalFolder2\input.txt"
config key is : "conditionalFolder2/input.txt"
lookup matches? : false
Because the lookup misses, shouldGenerate stays true and the file is generated even when its condition fails. An end-to-end run against the repository's own test template, with singleFile: 'true' (which fails the enum: ["false"] validation), shows the top-level cases behaving correctly while the nested one does not:
conditionalFile.txt exists (expected false): false
conditionalFolder exists (expected false): false
conditionalFolder2/input.txt exists (expected false): true <-- bug
The existing nested-path test only asserts the "should generate" direction, so it passes either way and the regression is invisible on the Windows CI leg.
There is a second, platform-independent part. When a conditionalFiles entry matches, the code sets conditionalPath to the top-level directory rather than the file key:
conditionalPath = relativeSourceDirectory;
so isGenerationConditionMet finds no config for that path and returns undefined. On POSIX that means a file whose condition is met gets skipped. The documented example in configuration-file.md uses a nested key, so documented usage is affected.
Expected behavior
A nested conditionalGeneration or conditionalFiles key is matched on every platform, and a matching conditionalFiles entry is evaluated against its own key.
How to Reproduce
Run the generator on Windows with a template whose config has a nested conditionalGeneration key and a parameter that fails the condition; the file is generated anyway. Output above is from executed runs.
I have a fix with regression tests ready and would like to open a PR for this.
Generated-by: Claude Code 2.x
AI assisted in investigating this bug and drafting this issue. I have reviewed and verified the analysis and the reproduction output myself.
Describe the bug
conditionalGeneration(and the deprecatedconditionalFiles) keys are written with POSIX separators in a template's config, for exampleconditionalFolder2/input.txt. The lookups inapps/generator/lib/generator.jsbuild their key withpath.relative, which returns backslashes on Windows, so a nested key never matches and the condition is silently ignored.Executed on
win32:Because the lookup misses,
shouldGeneratestaystrueand the file is generated even when its condition fails. An end-to-end run against the repository's own test template, withsingleFile: 'true'(which fails theenum: ["false"]validation), shows the top-level cases behaving correctly while the nested one does not:The existing nested-path test only asserts the "should generate" direction, so it passes either way and the regression is invisible on the Windows CI leg.
There is a second, platform-independent part. When a
conditionalFilesentry matches, the code setsconditionalPathto the top-level directory rather than the file key:so
isGenerationConditionMetfinds no config for that path and returnsundefined. On POSIX that means a file whose condition is met gets skipped. The documented example inconfiguration-file.mduses a nested key, so documented usage is affected.Expected behavior
A nested
conditionalGenerationorconditionalFileskey is matched on every platform, and a matchingconditionalFilesentry is evaluated against its own key.How to Reproduce
Run the generator on Windows with a template whose config has a nested
conditionalGenerationkey and a parameter that fails the condition; the file is generated anyway. Output above is from executed runs.I have a fix with regression tests ready and would like to open a PR for this.
Generated-by: Claude Code 2.x
AI assisted in investigating this bug and drafting this issue. I have reviewed and verified the analysis and the reproduction output myself.