diff --git a/src/__tests__/list_commands.test.ts b/src/__tests__/list_commands.test.ts index bbdefc08..3297dc47 100644 --- a/src/__tests__/list_commands.test.ts +++ b/src/__tests__/list_commands.test.ts @@ -18,24 +18,24 @@ describe('listCommands', () => { path.join(__dirname, 'fixtures', 'insertInHeaderAndFooter.docx') ); expect(await listCommands(template)).toMatchInlineSnapshot(` -Array [ - Object { - "code": "body_command", - "raw": "INS body_command", - "type": "INS", - }, - Object { - "code": "header_command", - "raw": "INS header_command", - "type": "INS", - }, - Object { - "code": "footer_command", - "raw": "INS footer_command", - "type": "INS", - }, -] -`); + Array [ + Object { + "code": "body_command", + "raw": "INS body_command", + "type": "INS", + }, + Object { + "code": "footer_command", + "raw": "INS footer_command", + "type": "INS", + }, + Object { + "code": "header_command", + "raw": "INS header_command", + "type": "INS", + }, + ] + `); }); it('handles IMAGE', async () => { @@ -53,19 +53,19 @@ Array [ path.join(__dirname, 'fixtures', 'imageHeader.docx') ); expect(await listCommands(template, '+++')).toMatchInlineSnapshot(` -Array [ - Object { - "code": "image()", - "raw": "IMAGE image()", - "type": "IMAGE", - }, - Object { - "code": "image()", - "raw": "IMAGE image()", - "type": "IMAGE", - }, -] -`); + Array [ + Object { + "code": "image()", + "raw": "IMAGE image()", + "type": "IMAGE", + }, + Object { + "code": "image()", + "raw": "IMAGE image()", + "type": "IMAGE", + }, + ] + `); }); it('handles inline FOR loops', async () => { diff --git a/src/main.ts b/src/main.ts index 90af2f7a..e0ebfc86 100644 --- a/src/main.ts +++ b/src/main.ts @@ -87,6 +87,9 @@ async function prepSecondaryXMLs( } }); + // Sort to ensure deterministic processing. + secondary_xml_files.sort(); + const prepped_secondaries: [Node, string][] = []; for (const f of secondary_xml_files) { const raw = await zipGetText(zip, f);