mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
Recursively delete folders in database projects (#14740)
* Recursively rmdir * Remove comment * Add test * Add test assertions * Comment * Recursively rmdir * Revert "Comment" This reverts commit 287e7f824adfb2fcedb18ee222b34b8c6a5305b5. * Re-commit Simplify Test
This commit is contained in:
@@ -263,7 +263,7 @@ export class Project {
|
||||
* Adds a folder to the project, and saves the project file
|
||||
* @param relativeFolderPath Relative path of the folder
|
||||
*/
|
||||
public async addFolderItem(relativeFolderPath: string): Promise<ProjectEntry> {
|
||||
public async addFolderItem(relativeFolderPath: string): Promise<FileProjectEntry> {
|
||||
const absoluteFolderPath = path.join(this.projectFolderPath, relativeFolderPath);
|
||||
|
||||
//If folder doesn't exist, create it
|
||||
@@ -347,13 +347,10 @@ export class Project {
|
||||
public async deleteFileFolder(entry: FileProjectEntry): Promise<void> {
|
||||
// compile a list of folder contents to delete; if entry is a file, contents will contain only itself
|
||||
const toDeleteFiles: FileProjectEntry[] = this.files.concat(this.preDeployScripts).concat(this.postDeployScripts).concat(this.noneDeployScripts).filter(x => x.fsUri.fsPath.startsWith(entry.fsUri.fsPath) && x.type === EntryType.File);
|
||||
const toDeleteFolders: FileProjectEntry[] = this.files.filter(x => x.fsUri.fsPath.startsWith(entry.fsUri.fsPath) && x.type === EntryType.Folder).sort(x => -x.relativePath.length);
|
||||
const toDeleteFolders: FileProjectEntry[] = this.files.filter(x => x.fsUri.fsPath.startsWith(entry.fsUri.fsPath) && x.type === EntryType.Folder);
|
||||
|
||||
await Promise.all(toDeleteFiles.map(x => fs.unlink(x.fsUri.fsPath)));
|
||||
|
||||
for (const folder of toDeleteFolders) {
|
||||
await fs.rmdir(folder.fsUri.fsPath); // TODO: replace .sort() and iteration with rmdir recursive flag once that's unbugged
|
||||
}
|
||||
await Promise.all(toDeleteFolders.map(x => fs.rmdir(x.fsUri.fsPath, { recursive: true })));
|
||||
|
||||
await this.exclude(entry);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user