mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-16 19:46:19 +02:00
refactor logic for existing file check based on paths
This commit is contained in:
@@ -95,3 +95,15 @@ export function doesFileExistInFolder(folder, fileName) {
|
||||
const details = getChildFileFromName(folder.children, fileName);
|
||||
return !!details.file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parent path of passed path
|
||||
* @param {string} path Path of file to find parent of
|
||||
*/
|
||||
export function getParentPath(path) {
|
||||
const pathPieces = path.split('/');
|
||||
if (pathPieces.length > 1) {
|
||||
return pathPieces.slice(0, -1).join('/');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
Reference in New Issue
Block a user