t3-code-android-nightly/.repos/effect-smol/packages/tools/api-diff/test/utils.ts
2026-09-07 21:54:44 -07:00

37 lines
1 KiB
TypeScript

import * as Effect from "effect/Effect"
import * as FileSystem from "effect/FileSystem"
import * as Path from "effect/Path"
export const writeFixturePackage = Effect.fnUntraced(function*(
repoRoot: string,
files: Readonly<Record<string, string>>,
exports: Readonly<Record<string, unknown>> = {
".": "./index.js",
"./*": "./*.js",
"./internal/*": null
}
) {
const fs = yield* FileSystem.FileSystem
const path = yield* Path.Path
const root = path.join(repoRoot, "packages", "sample", "dist")
yield* fs.makeDirectory(root, { recursive: true })
yield* fs.writeFileString(
path.join(root, "package.json"),
`${
JSON.stringify(
{
name: "@fixture/sample",
version: "1.0.0",
exports
},
null,
2
)
}\n`
)
for (const [name, source] of Object.entries(files)) {
const location = path.join(root, name)
yield* fs.makeDirectory(path.dirname(location), { recursive: true })
yield* fs.writeFileString(location, source)
}
})