From 1480c6ce91486b0557d590d95fad335b252b7473 Mon Sep 17 00:00:00 2001 From: Daluworks Date: Sun, 18 Oct 2026 18:13:24 +0100 Subject: [PATCH] Make template traversal deterministic across platforms --- src/generator/template-generation.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/generator/template-generation.ts b/src/generator/template-generation.ts index ed79f15..8d20504 100644 --- a/src/generator/template-generation.ts +++ b/src/generator/template-generation.ts @@ -71,9 +71,11 @@ function copyTemplateTree( variables: Readonly>, ): void { const sourceDirectory = resolve(templateRoot, relativeDirectory); - const entries = readdirSync(sourceDirectory, { withFileTypes: true }).sort( - (a, b) => a.name.localeCompare(b.name), - ); + const entries = readdirSync(sourceDirectory, { withFileTypes: true }).sort((a, b) => { + if (a.name < b.name) return -1; + if (a.name > b.name) return 1; + return 0; + }); for (const entry of entries) { assertSafeEntryName(entry.name);