MCPcopy
hub / github.com/vitest-dev/vitest / writeFile

Function writeFile

packages/browser/src/node/commands/fs.ts:40–49  ·  view source on GitHub ↗
({ project }, path, data, options)

Source from the content-addressed store, hash-verified

38export const writeFile: BrowserCommand<
39 Parameters<BrowserCommands['writeFile']>
40> = async ({ project }, path, data, options) => {
41 assertWrite(path, project)
42 const filepath = resolve(project.config.root, path)
43 assertFileAccess(slash(filepath), project)
44 const dir = dirname(filepath)
45 if (!fs.existsSync(dir)) {
46 await fsp.mkdir(dir, { recursive: true })
47 }
48 await fsp.writeFile(filepath, data, options)
49}
50
51export const removeFile: BrowserCommand<
52 Parameters<BrowserCommands['removeFile']>

Callers 10

writeScreenshotFunction · 0.85
updatePkgJsonScriptsFunction · 0.85
endMethod · 0.85
ensureCacheIntegrityMethod · 0.85
atomicWriteFileFunction · 0.85
writeBlobFunction · 0.85
commands.test.tsFile · 0.85
imports.test.tsFile · 0.85
cleanupFunction · 0.85

Calls 4

slashFunction · 0.90
assertWriteFunction · 0.85
assertFileAccessFunction · 0.85
resolveFunction · 0.50

Tested by 1

cleanupFunction · 0.68