MCPcopy
hub / github.com/remix-run/react-router / createProject

Function createProject

integration/helpers/vite.ts:262–284  ·  view source on GitHub ↗
(
  files: Record<string, string> = {},
  templateName: TemplateName = "vite-7-template",
)

Source from the content-addressed store, hash-verified

260}>;
261
262export async function createProject(
263 files: Record<string, string> = {},
264 templateName: TemplateName = "vite-7-template",
265) {
266 let projectName = `rr-${Math.random().toString(32).slice(2)}`;
267 let projectDir = path.join(TMP_DIR, projectName);
268 await mkdir(projectDir, { recursive: true });
269
270 // base template
271 let templateDir = path.resolve(__dirname, templateName);
272 await cp(templateDir, projectDir, { errorOnExist: true, recursive: true });
273
274 // user-defined files
275 await Promise.all(
276 Object.entries(files).map(async ([filename, contents]) => {
277 let filepath = path.join(projectDir, filename);
278 await mkdir(path.dirname(filepath), { recursive: true });
279 await writeFile(filepath, stripIndent(contents));
280 }),
281 );
282
283 return projectDir;
284}
285
286// Avoid "Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env
287// being set" in vite-ecosystem-ci which breaks empty stderr assertions. To fix

Calls 1

writeFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…