MCPcopy Create free account
hub / github.com/angular/angular / createProject

Function createProject

packages/compiler-cli/preprocessor/test/ngp_spec.ts:203–219  ·  view source on GitHub ↗

Writes a fixture project with `files` (relative path → content) into a fresh temp dir.

(files: Record<string, string>)

Source from the content-addressed store, hash-verified

201
202 /** Writes a fixture project with `files` (relative path → content) into a fresh temp dir. */
203 async function createProject(files: Record<string, string>): Promise<void> {
204 tempDir = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), 'ngp-unchanged-test-')));
205 tsconfigPath = path.join(tempDir, 'tsconfig.json');
206
207 const nodeModules = getOrCreateSyntheticNodeModules();
208 if (nodeModules) {
209 await fs.symlink(nodeModules, path.join(tempDir, 'node_modules'), 'dir');
210 }
211
212 const tsconfig = {compilerOptions: {strict: true}, files: Object.keys(files)};
213 await fs.writeFile(tsconfigPath, JSON.stringify(tsconfig));
214 await Promise.all(
215 Object.entries(files).map(([name, content]) =>
216 fs.writeFile(path.join(tempDir, name), content),
217 ),
218 );
219 }
220
221 const runNgp = (...args: string[]) =>
222 execFileSync(

Callers 1

ngp_spec.tsFile · 0.85

Calls 9

mapMethod · 0.80
realpathMethod · 0.65
joinMethod · 0.65
symlinkMethod · 0.65
keysMethod · 0.65
writeFileMethod · 0.65
allMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected