// files.ts:
export const progCopyFiles = (
sourcePath: string,
targetPath: string,
options: FileSystem.CopyOptions,
) =>
Effect.gen(function* () {
const sourceExist = yield* doesPathExist(sourcePath);
const targetExist = yield* doesPathExist(targetPath);
if (!sourceExist || !targetExist) {
return false;
}
const fs = yield* FileSystem.FileSystem;
yield* fs.copy(sourcePath, targetPath, options);
return true;
}).pipe(
Effect.catchAll((error) => {
Effect.log(`[unicorn_juice] Error copying files: ${error.message}`);
return Effect.succeed(false);
}),
);
// main.ts:
// ...
const didAssetsCopy = await Effect.runPromise(
progCopyFiles(studioFolder, distFolder, { overwrite: true }).pipe(
Effect.provide(NodeContext.layer),
),
);
// ...
// files.ts:
export const progCopyFiles = (
sourcePath: string,
targetPath: string,
options: FileSystem.CopyOptions,
) =>
Effect.gen(function* () {
const sourceExist = yield* doesPathExist(sourcePath);
const targetExist = yield* doesPathExist(targetPath);
if (!sourceExist || !targetExist) {
return false;
}
const fs = yield* FileSystem.FileSystem;
yield* fs.copy(sourcePath, targetPath, options);
return true;
}).pipe(
Effect.catchAll((error) => {
Effect.log(`[unicorn_juice] Error copying files: ${error.message}`);
return Effect.succeed(false);
}),
);
// main.ts:
// ...
const didAssetsCopy = await Effect.runPromise(
progCopyFiles(studioFolder, distFolder, { overwrite: true }).pipe(
Effect.provide(NodeContext.layer),
),
);
// ...