MCPcopy Create free account
hub / github.com/Effect-TS/effect / writeFileToOutDir

Function writeFileToOutDir

packages/tools/docgen/src/Core.ts:80–104  ·  view source on GitHub ↗
(file: Domain.File)

Source from the content-addressed store, hash-verified

78 * Writes a file to the `config.outDir` directory, taking into account the configuration and existing files.
79 */
80const writeFileToOutDir = (file: Domain.File) =>
81 Effect.gen(function*() {
82 const config = yield* Configuration.Configuration
83 const fs = yield* FileSystem.FileSystem
84 const path = yield* Path.Path
85 const process = yield* Domain.Process
86 const cwd = yield* process.cwd
87 const fileName = path.relative(path.join(cwd, config.outDir), file.path)
88
89 const exists = yield* fs.exists(file.path)
90 if (exists) {
91 if (file.isOverwriteable) {
92 yield* Effect.logDebug(`Overwriting file ${chalk.black(fileName)}...`)
93 yield* fs.makeDirectory(path.dirname(file.path), { recursive: true })
94 yield* fs.writeFileString(file.path, file.content)
95 } else {
96 yield* Effect.logDebug(
97 `File ${chalk.black(fileName)} already exists, skipping creation.`
98 )
99 }
100 } else {
101 yield* fs.makeDirectory(path.dirname(file.path), { recursive: true })
102 yield* fs.writeFileString(file.path, file.content)
103 }
104 })
105
106const writeFilesToOutDir = (
107 files: ReadonlyArray<Domain.File>

Callers 1

Core.tsFile · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected