MCPcopy Index your code
hub / github.com/deepnote/deepnote / writeDeepnoteFile

Function writeDeepnoteFile

packages/convert/src/write-deepnote-file.ts:38–67  ·  view source on GitHub ↗
(options: WriteDeepnoteFileOptions)

Source from the content-addressed store, hash-verified

36 * @returns Object containing paths to the written files
37 */
38export async function writeDeepnoteFile(options: WriteDeepnoteFileOptions): Promise<WriteDeepnoteFileResult> {
39 const { file, outputPath, projectName, singleFile = false } = options
40
41 // Ensure parent directory exists
42 const parentDir = dirname(outputPath)
43 await fs.mkdir(parentDir, { recursive: true })
44
45 // If singleFile mode or no outputs, write complete file
46 if (singleFile || !hasOutputs(file)) {
47 const yamlContent = serializeDeepnoteFile(file)
48 await fs.writeFile(outputPath, yamlContent, 'utf-8')
49 return { sourcePath: outputPath }
50 }
51
52 // Split into source and snapshot in memory
53 const { source, snapshot } = splitDeepnoteFile(file)
54
55 const snapshotDir = getSnapshotDir(outputPath)
56 const snapshotPath = getSnapshotPath(outputPath, file, { projectName })
57
58 // Serialize both files
59 const sourceYaml = serializeDeepnoteFile(source)
60 const snapshotYaml = serializeDeepnoteSnapshot(snapshot)
61
62 // Create snapshot directory and write both files in parallel
63 await fs.mkdir(snapshotDir, { recursive: true })
64 await Promise.all([fs.writeFile(outputPath, sourceYaml, 'utf-8'), fs.writeFile(snapshotPath, snapshotYaml, 'utf-8')])
65
66 return { sourcePath: outputPath, snapshotPath }
67}

Callers 2

convertDirectoryFunction · 0.90

Calls 6

hasOutputsFunction · 0.90
serializeDeepnoteFileFunction · 0.90
splitDeepnoteFileFunction · 0.90
getSnapshotDirFunction · 0.90
getSnapshotPathFunction · 0.90

Tested by

no test coverage detected