Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun #1183

Merged
merged 25 commits into from
Sep 12, 2023
Prev Previous commit
Next Next commit
fix
  • Loading branch information
jxom committed Sep 10, 2023
commit b930ab35995873207abf974107023ba713cbaf1b
38 changes: 22 additions & 16 deletions scripts/generateTypedArtifacts.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import path from 'node:path'
import { globby } from 'globby'

const generatedPath = `${import.meta.dir}/generated.ts`
const generatedPath = path.join(
import.meta.dir,
'../test/contracts/generated.ts',
)
Bun.write(generatedPath, '')

globby([`${import.meta.dir}/out/**/*.json`]).then((paths) => {
const generated = Bun.file(generatedPath)
const writer = generated.writer()
globby([path.join(import.meta.dir, '../test/contracts/out/**/*.json')]).then(
(paths) => {
const generated = Bun.file(generatedPath)
const writer = generated.writer()

paths.forEach(async (path) => {
const fileName = path.split('/').pop()?.replace('.json', '')
const json = await Bun.file(path, { type: 'application/json' }).json()
writer.write(
`export const ${fileName} = ${JSON.stringify(
json,
null,
2,
)} as const;\n\n`,
)
})
})
paths.forEach(async (path) => {
const fileName = path.split('/').pop()?.replace('.json', '')
const json = await Bun.file(path, { type: 'application/json' }).json()
writer.write(
`export const ${fileName} = ${JSON.stringify(
json,
null,
2,
)} as const;\n\n`,
)
})
},
)