( path: string, fileTree: FileTree, )
| 25 | }; |
| 26 | |
| 27 | export const validatePath = ( |
| 28 | path: string, |
| 29 | fileTree: FileTree, |
| 30 | ): string | undefined => { |
| 31 | const paths = path.split("/"); |
| 32 | paths.pop(); // The last item is the filename |
| 33 | for (let i = 0; i <= paths.length; i++) { |
| 34 | const path = paths.slice(0, i + 1); |
| 35 | const pathStr = path.join("/"); |
| 36 | if (existsFile(pathStr, fileTree) && !isFolder(pathStr, fileTree)) { |
| 37 | return `Invalid path. The path ${path} is not a folder`; |
| 38 | } |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | export const updateFile = ( |
| 43 | path: string, |
no test coverage detected