load publish profile sqlcmd "value" tag and throw error if not loaded correctly (#11615)

* load publish profile sqlcmd "value" tag and throw error if not loaded correctly

* moved the read profile function to utils
This commit is contained in:
Udeesha Gautam
2020-08-03 14:16:00 -07:00
committed by GitHub
parent 9d730bd0b5
commit fbbb9ce529
7 changed files with 24 additions and 29 deletions

View File

@@ -127,12 +127,18 @@ export function convertSlashesForSqlProj(filePath: string): string {
*/
export function readSqlCmdVariables(xmlDoc: any): Record<string, string> {
let sqlCmdVariables: Record<string, string> = {};
for (let i = 0; i < xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable).length; i++) {
for (let i = 0; i < xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable)?.length; i++) {
const sqlCmdVar = xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable)[i];
const varName = sqlCmdVar.getAttribute(constants.Include);
const varValue = sqlCmdVar.getElementsByTagName(constants.DefaultValue)[0].childNodes[0].nodeValue;
sqlCmdVariables[varName] = varValue;
if (sqlCmdVar.getElementsByTagName(constants.DefaultValue)[0] !== undefined) {
// project file path
sqlCmdVariables[varName] = sqlCmdVar.getElementsByTagName(constants.DefaultValue)[0].childNodes[0].nodeValue;
}
else {
// profile path
sqlCmdVariables[varName] = sqlCmdVar.getElementsByTagName(constants.Value)[0].childNodes[0].nodeValue;
}
}
return sqlCmdVariables;