MCPcopy Create free account
hub / github.com/vercel/vercel / prepareFilesystem

Function prepareFilesystem

packages/node/test/unit/test-utils.ts:16–42  ·  view source on GitHub ↗
(
  files: Fs,
  folderPrefix = 'vercel-node-tests',
  workPathPrefix = ''
)

Source from the content-addressed store, hash-verified

14};
15
16export async function prepareFilesystem(
17 files: Fs,
18 folderPrefix = 'vercel-node-tests',
19 workPathPrefix = ''
20): Promise<Filesystem> {
21 const directory = join(tmpdir(), `${folderPrefix}-${Date.now()}`);
22 const workPath = workPathPrefix ? join(directory, workPathPrefix) : directory;
23 await fs.mkdir(workPath, { recursive: true });
24 const fileRefs: Files = {};
25 for (const [key, value] of Object.entries(files)) {
26 const fullPath = join(workPath, key);
27 await fs.mkdir(dirname(fullPath), { recursive: true });
28 if (typeof value === 'string' || value instanceof Buffer) {
29 await fs.writeFile(join(workPath, key), value);
30 } else if (typeof value.copy === 'string') {
31 await fs.copyFile(join(workPath, value.copy), join(workPath, key));
32 }
33 fileRefs[key] = await FileFsRef.fromFsPath({
34 fsPath: join(workPath, key),
35 });
36 }
37 return {
38 workPath,
39 repoRootPath: directory,
40 files: fileRefs,
41 };
42}
43
44export async function prepareFixtureFilesystem(
45 fixtureName: string,

Calls 1

fromFsPathMethod · 0.80

Tested by

no test coverage detected