( currentPath: string, newPath: string, fileTree: FileTree, )
| 59 | }; |
| 60 | |
| 61 | export 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 | |
| 75 | export const getFileContent = (path: string, fileTree: FileTree) => { |
| 76 | return get(fileTree, path.split("/")) as string | FileTree; |
no test coverage detected