mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 17:22:29 -05:00
* Add clean target * include in test baselines * adding one more test
This commit is contained in:
@@ -78,6 +78,7 @@ export class Project {
|
||||
await fs.copyFile(this.projectFilePath, this.projectFilePath + '_backup');
|
||||
await this.updateImportToSupportRoundTrip();
|
||||
await this.updatePackageReferenceInProjFile();
|
||||
await this.updateAfterCleanTargetInProjFile();
|
||||
}
|
||||
|
||||
private async updateImportToSupportRoundTrip(): Promise<void> {
|
||||
@@ -99,6 +100,30 @@ export class Project {
|
||||
await this.updateImportedTargetsToProjFile(constants.NetCoreCondition, constants.NetCoreTargets, undefined);
|
||||
}
|
||||
|
||||
private async updateAfterCleanTargetInProjFile(): Promise<void> {
|
||||
// Search if clean target already present, update it
|
||||
for (let i = 0; i < this.projFileXmlDoc.documentElement.getElementsByTagName(constants.Target).length; i++) {
|
||||
const afterCleanNode = this.projFileXmlDoc.documentElement.getElementsByTagName(constants.Target)[i];
|
||||
const name = afterCleanNode.getAttribute(constants.Name);
|
||||
if (name === constants.AfterCleanTarget) {
|
||||
return await this.createCleanFileNode(afterCleanNode);
|
||||
}
|
||||
}
|
||||
|
||||
// If clean target not found, create new
|
||||
const afterCleanNode = this.projFileXmlDoc.createElement(constants.Target);
|
||||
afterCleanNode.setAttribute(constants.Name, constants.AfterCleanTarget);
|
||||
this.projFileXmlDoc.documentElement.appendChild(afterCleanNode);
|
||||
await this.createCleanFileNode(afterCleanNode);
|
||||
}
|
||||
|
||||
private async createCleanFileNode(parentNode: any): Promise<void> {
|
||||
const deleteFileNode = this.projFileXmlDoc.createElement(constants.Delete);
|
||||
deleteFileNode.setAttribute(constants.Files, constants.ProjJsonToClean);
|
||||
parentNode.appendChild(deleteFileNode);
|
||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a folder to the project, and saves the project file
|
||||
* @param relativeFolderPath Relative path of the folder
|
||||
|
||||
Reference in New Issue
Block a user