MCPcopy Index your code
hub / github.com/SoCreate/angular-playground / buildSandboxFileContents

Function buildSandboxFileContents

projects/cli/src/build-sandboxes.ts:91–115  ·  view source on GitHub ↗
(
    rootPath: string,
    sandboxes: SandboxFileInformation[],
    chunkMode: string,
    writeContents: (file, contents) => Promise<string>)

Source from the content-addressed store, hash-verified

89}
90
91export function buildSandboxFileContents(
92 rootPath: string,
93 sandboxes: SandboxFileInformation[],
94 chunkMode: string,
95 writeContents: (file, contents) => Promise<string>) {
96 const promises: Promise<string>[] = [];
97
98 const filename = joinPath(rootPath, 'sandboxes.ts');
99 createSandboxesFileIfNotExists(filename);
100
101 let contents = readFileSync(filename, 'utf8');
102
103 if (contents.indexOf('*GET_SANDBOX*') !== -1) {
104 const sandboxMenuItemsMethodBody = buildGetSandboxMenuItemMethodBodyContent(sandboxes);
105 contents = contents.replace(
106 /(\/\*GET_SANDBOX_MENU_ITEMS\*\/).*?(?=\/\*END_GET_SANDBOX_MENU_ITEMS\*\/)/s,
107 `$1\n ${sandboxMenuItemsMethodBody} \n`
108 );
109 const sandboxMethodBody = buildGetSandboxMethodBodyContent(sandboxes, chunkMode);
110 contents = contents.replace(/(\/\*GET_SANDBOX\*\/).*?(?=\/\*END_GET_SANDBOX\*\/)/s, `$1\n ${sandboxMethodBody} \n`);
111 promises.push(writeContents(filename, contents));
112 }
113
114 return Promise.all(promises);
115}
116
117export function createSandboxesFileIfNotExists(filename: string) {
118 if (!existsSync(filename)) {

Callers 2

buildSandboxesFunction · 0.85

Tested by

no test coverage detected