MCPcopy
hub / github.com/marktext/marktext / writeFile

Function writeFile

packages/desktop/src/main/filesystem/index.ts:24–38  ·  view source on GitHub ↗
(
  pathname: string,
  content: string | Buffer,
  extension?: string,
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  options: BufferEncoding | { encoding?: BufferEncoding } | undefined | any = 'utf-8'
)

Source from the content-addressed store, hash-verified

22}
23
24export const writeFile = (
25 pathname: string,
26 content: string | Buffer,
27 extension?: string,
28 // eslint-disable-next-line @typescript-eslint/no-explicit-any
29 options: BufferEncoding | { encoding?: BufferEncoding } | undefined | any = 'utf-8'
30): Promise<void> => {
31 if (!pathname) {
32 return Promise.reject(new Error('[ERROR] Cannot save file without path.'))
33 }
34 pathname = !extension || pathname.endsWith(extension) ? pathname : `${pathname}${extension}`
35
36 // eslint-disable-next-line @typescript-eslint/no-explicit-any
37 return outputFile(pathname, content as any, options)
38}

Callers 2

handleResponseForExportFunction · 0.90
writeMarkdownFileFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected