MCPcopy Index your code
hub / github.com/freshframework/fresh / copyRecursive

Function copyRecursive

packages/init/src/init_test.ts:106–132  ·  view source on GitHub ↗
(
  from: string,
  to: string,
  ignore?: (entry: Deno.DirEntry, full: string) => boolean,
)

Source from the content-addressed store, hash-verified

104}
105
106async function copyRecursive(
107 from: string,
108 to: string,
109 ignore?: (entry: Deno.DirEntry, full: string) => boolean,
110): Promise<void> {
111 for await (const entry of Deno.readDir(from)) {
112 const source = path.join(from, entry.name);
113 const target = path.join(to, entry.name);
114
115 if (ignore && ignore(entry, source)) {
116 continue;
117 }
118
119 if (entry.isFile) {
120 try {
121 await Deno.mkdir(to, { recursive: true });
122 } catch (err) {
123 if (!(err instanceof Deno.errors.AlreadyExists)) {
124 throw err;
125 }
126 }
127 await Deno.copyFile(source, target);
128 } else if (entry.isDirectory) {
129 await copyRecursive(source, target, ignore);
130 }
131 }
132}
133
134async function expectProjectFile(dir: string, pathname: string) {
135 const filePath = path.join(dir, ...pathname.split("/").filter(Boolean));

Callers 1

patchProjectFunction · 0.85

Calls 1

ignoreFunction · 0.85

Tested by

no test coverage detected