Skip to content

Commit

Permalink
Add more deterministic file sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Aug 23, 2023
1 parent 0187cc7 commit 831ebe8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ test("prints list of matched files with --list-files option", async () => {
expect(code).toBe(0);
expect(stdout).toMatchInlineSnapshot(`
[
"src/query.graphql",
"src/components/legacy.js",
"src/components/my-component.tsx",
"src/queries/root.graphql",
"src/query.graphql",
]
`);

Expand Down
6 changes: 5 additions & 1 deletion packages/generate-persisted-query-manifest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,12 @@ function uniq<T>(arr: T[]) {
return [...new Set(arr)];
}

// Unfortunately globby does not guarantee deterministic file sorting so we
// apply some sorting on the files in this function.
//
// https://github.com/sindresorhus/globby/issues/131
export async function getFilepaths(documents: string | string[]) {
return uniq(await globby(documents));
return [...uniq(await globby(documents))].sort((a, b) => a.localeCompare(b));
}

export async function generatePersistedQueryManifest(
Expand Down

0 comments on commit 831ebe8

Please sign in to comment.