Handle exclude folder for sdk style sql projects (#17826)

* handle exclude Folder for sdk style projects

* update comment

* fix tests

* cleanup

* handle nested folders

* cleanup

* addressing comments
This commit is contained in:
Kim Santiago
2021-12-14 11:29:42 -08:00
committed by GitHub
parent be933c88c0
commit 2b1acbc2c7
7 changed files with 205 additions and 21 deletions

View File

@@ -578,3 +578,28 @@ export async function getFoldersInFolder(folderPath: string, ignoreBinObj?: bool
return await glob(folderFilter, { onlyDirectories: true });
}
}
/**
* Gets the folders between the startFolder to the file
* @param startFolder
* @param endFile
* @returns array of folders between startFolder and endFile
*/
export function getFoldersToFile(startFolder: string, endFile: string): string[] {
let folders: string[] = [];
const endFolderPath = path.dirname(endFile);
const relativePath = convertSlashesForSqlProj(endFolderPath.substring(startFolder.length));
const pathSegments = trimChars(relativePath, ' \\').split(constants.SqlProjPathSeparator);
let folderPath = convertSlashesForSqlProj(startFolder) + constants.SqlProjPathSeparator;
for (let segment of pathSegments) {
if (segment) {
folderPath += segment + constants.SqlProjPathSeparator;
folders.push(getPlatformSafeFileEntryPath(folderPath));
}
}
return folders;
}