Skip to content

Commit

Permalink
Ensure deterministic processing for easier debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhbw committed Oct 29, 2022
1 parent 706a7a4 commit 8b2ba55
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
62 changes: 31 additions & 31 deletions src/__tests__/list_commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8b2ba55

Please sign in to comment.