Open History to see the last commit
1import * as Effect from "effect/Effect";
2import * as FileSystem from "effect/FileSystem";
3import * as Path from "effect/Path";
4
5import { ServerCliBuildAssetMissingError } from "./cliErrors.ts";
6
7export const copyRequiredBuildAsset = Effect.fn("copyRequiredBuildAsset")(function* (
8 sourcePath: string,
9 targetPath: string,
10) {
11 const fileSystem = yield* FileSystem.FileSystem;
12 const path = yield* Path.Path;
13
14 if (!(yield* fileSystem.exists(sourcePath))) {
15 return yield* new ServerCliBuildAssetMissingError({ assetPath: sourcePath });
16 }
17
18 yield* fileSystem.makeDirectory(path.dirname(targetPath), { recursive: true });
19 yield* fileSystem.copyFile(sourcePath, targetPath);
20});