Skip to content

Commit

Permalink
fix: the ordering of the contractMap key (#2547)
Browse files Browse the repository at this point in the history
* fix: the ordering of the contractMap key

* chore: changeset

---------

Co-authored-by: Tom Meagher <[email protected]>
  • Loading branch information
Iamshankhadeep and tmm authored Aug 31, 2023
1 parent 1c3228b commit 8c3889f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-poems-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wagmi/cli": patch
---

Deterministic CLI output
9 changes: 7 additions & 2 deletions packages/cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ export async function generate(options: Generate = {}) {
)
const contract = await getContract({ ...contractConfig, isTypeScript })
contractMap.set(contract.name, contract)

contractNames.add(contractConfig.name)
}

const contracts = [...contractMap.values()]
// Sort contracts by name Ascending (low to high) as the key is `String`
const sortedAscContractMap = new Map([...contractMap].sort())
const contracts = [...sortedAscContractMap.values()]
if (!contracts.length && !options.watch) {
spinner.fail()
logger.warn('No contracts found.')
Expand Down Expand Up @@ -200,7 +203,9 @@ export async function generate(options: Generate = {}) {
if (timeout) clearTimeout(timeout)
timeout = setTimeout(async () => {
timeout = null
const contracts = [...contractMap.values()]
// Sort contracts by name Ascending (low to high) as the key is `String`
const sortedAscContractMap = new Map([...contractMap].sort())
const contracts = [...sortedAscContractMap.values()]
const imports = []
const prepend = []
const content = []
Expand Down

1 comment on commit 8c3889f

@vercel
Copy link

@vercel vercel bot commented on 8c3889f Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.