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

Function patchProject

packages/init/src/init_test.ts:52–104  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

50}
51
52async function patchProject(dir: string): Promise<void> {
53 const jsonPath = path.join(dir, "deno.json");
54 const json = JSON.parse(await Deno.readTextFile(jsonPath));
55
56 const linkedDir = path.join(dir, "_linked");
57 try {
58 await Deno.mkdir(linkedDir, { recursive: true });
59 } catch (err) {
60 if (!(err instanceof Deno.errors.AlreadyExists)) {
61 throw err;
62 }
63 }
64
65 const ignore = (entry: Deno.DirEntry, _full: string) => {
66 return /^(\.|tmp_)/.test(entry.name) ||
67 /_test\.[tj]sx?$/.test(entry.name) ||
68 entry.name === "tests" || entry.name === "test";
69 };
70
71 await copyRecursive(
72 path.join(import.meta.dirname!, "..", "..", "fresh"),
73 path.join(linkedDir, "fresh"),
74 ignore,
75 );
76
77 await copyRecursive(
78 path.join(import.meta.dirname!, "..", "..", "build-id"),
79 path.join(linkedDir, "build-id"),
80 ignore,
81 );
82
83 json.workspace = ["./_linked/*"];
84 json.exclude = [...json.exclude ?? [], "**/_linked/*"];
85
86 // assert with this stricter rule, before adding it to initialized projects
87 json.lint.rules.include = ["verbatim-module-syntax"];
88
89 await Deno.writeTextFile(jsonPath, JSON.stringify(json, null, 2) + "\n");
90 const installProc = await new Deno.Command(Deno.execPath(), {
91 cwd: dir,
92 args: ["install"],
93 }).output();
94
95 if (installProc.code !== 0) {
96 const { stderr, stdout } = getStdOutput(installProc);
97 // deno-lint-ignore no-console
98 console.log(stderr);
99 // deno-lint-ignore no-console
100 console.log(stdout);
101 }
102
103 expect(installProc.code).toEqual(0);
104}
105
106async function copyRecursive(
107 from: string,

Callers 1

init_test.tsFile · 0.85

Calls 3

getStdOutputFunction · 0.90
copyRecursiveFunction · 0.85
readTextFileMethod · 0.80

Tested by

no test coverage detected