MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / createTemporaryFile

Function createTemporaryFile

src/test/common.web.ts:33–55  ·  view source on GitHub ↗
(options: {
            contents?: string;
            extension: string;
        })

Source from the content-addressed store, hash-verified

31export function initializeCommonWebApi() {
32 initializeCommonApi({
33 async createTemporaryFile(options: {
34 contents?: string;
35 extension: string;
36 }): Promise<{ file: Uri } & IDisposable> {
37 const folder = workspace.workspaceFolders![0].uri;
38 const tmpDir = Uri.joinPath(folder, 'temp', 'testFiles');
39 try {
40 await workspace.fs.createDirectory(tmpDir);
41 } catch {
42 // ignore if it exists..
43 }
44 const extension = options.extension || '.py';
45 const file = Uri.joinPath(tmpDir, `${generateUuid()}${extension}`);
46 const contents = options.contents || '';
47
48 await workspace.fs.writeFile(file, new TextEncoder().encode(contents));
49 return {
50 file,
51 dispose: () => {
52 workspace.fs.delete(file).then(noop, noop);
53 }
54 };
55 },
56 async startJupyterServer(_options?: {
57 token?: string;
58 port?: number;

Callers

nothing calls this directly

Calls 5

generateUuidFunction · 0.90
joinPathMethod · 0.65
createDirectoryMethod · 0.65
writeFileMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected