MCPcopy
hub / github.com/foambubble/foam / createFile

Function createFile

packages/foam-vscode/src/test/test-utils-vscode.ts:153–161  ·  view source on GitHub ↗
(content: string, filepath: string[] = [])

Source from the content-addressed store, hash-verified

151 * @returns an object containing various information about the file created
152 */
153export const createFile = async (content: string, filepath: string[] = []) => {
154 const uri = getUriInWorkspace(...filepath);
155 const filenameComponents = path.parse(uri.toFsPath());
156 await vscode.workspace.fs.writeFile(
157 toVsCodeUri(uri),
158 new TextEncoder().encode(content)
159 );
160 return { uri, content, ...filenameComponents };
161};
162
163export const renameFile = (from: URI, to: URI) => {
164 const edit = new vscode.WorkspaceEdit();

Calls 5

toVsCodeUriFunction · 0.90
getUriInWorkspaceFunction · 0.85
toFsPathMethod · 0.80
writeFileMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected