MCPcopy Index your code
hub / github.com/coder/coder / moveFile

Function moveFile

site/src/utils/filetree.ts:61–73  ·  view source on GitHub ↗
(
	currentPath: string,
	newPath: string,
	fileTree: FileTree,
)

Source from the content-addressed store, hash-verified

59};
60
61export const moveFile = (
62 currentPath: string,
63 newPath: string,
64 fileTree: FileTree,
65) => {
66 const content = getFileContent(currentPath, fileTree);
67 if (typeof content !== "string") {
68 throw new Error("Move folders is not allowed");
69 }
70 fileTree = removeFile(currentPath, fileTree);
71 fileTree = createFile(newPath, fileTree, content);
72 return fileTree;
73};
74
75export const getFileContent = (path: string, fileTree: FileTree) => {
76 return get(fileTree, path.split("/")) as string | FileTree;

Callers 2

filetree.test.tsFile · 0.90
TemplateVersionEditorFunction · 0.90

Calls 3

getFileContentFunction · 0.85
removeFileFunction · 0.85
createFileFunction · 0.70

Tested by

no test coverage detected