Skip to content

Commit 90330f7

Browse files
committed
Incorporate latest suggestions from PR
1 parent beafd41 commit 90330f7

3 files changed

Lines changed: 7 additions & 21 deletions

File tree

packages/office-addin-manifest/src/manifestInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function writeManifestData(manifestPath: string, manifestData: any): Promi
9797
}
9898

9999
try {
100-
// Write modified xml back to the manifest.
100+
// Write the xml back to the manifest file.
101101
await writeFileAsync(manifestPath, xml);
102102
} catch (err) {
103103
throw new Error(`Unable to write to file. ${manifestPath} \n${err}`);
Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// reading xml values is resilient to errors but you can uncomment the next line for debugging if attributes are missing
21
export function getXmlAttributeValue(xml: any, name: string): string | undefined {
32
try {
43
return xml.$[name];
54
} catch (err) {
5+
// reading xml values is resilient to errors but you can uncomment the next line for debugging if attributes are missing
66
// console.error(`Unable to get xml attribute value "${name}". ${err}`);
77
}
88
}
@@ -14,7 +14,6 @@ export function getXmlElementAttributeValue(xml: any, elementName: string, attri
1414
}
1515
}
1616

17-
// reading xml values is resilient to errors but you can uncomment the next line for debugging if elements are missing
1817
export function getXmlElementValue(xml: any, name: string): string | undefined {
1918
try {
2019
const element = xml[name];
@@ -23,29 +22,15 @@ export function getXmlElementValue(xml: any, name: string): string | undefined {
2322
return element[0];
2423
}
2524
} catch (err) {
26-
// console.error(`Unable to get xml element value "${name}". ${err}`);
25+
// reading xml values is resilient to errors but you can uncomment the next line for debugging if elements are missing
26+
// console.error(`Unable to get xml element value "${name}". ${err}`);
2727
}
2828
}
2929

3030
export function setXmlElementValue(xml: any, elementName: string, input: any) {
31-
const element = getXmlElementValue(xml, elementName);
32-
33-
if (element) {
34-
try {
35-
xml[elementName] = input;
36-
} catch (err) {
37-
console.error(`Unable to write value to xml element: ${err}`);
38-
}
39-
return xml;
40-
}
31+
xml[elementName] = input;
4132
}
4233

4334
export function setElementAttributeValue(xml: any, elementName: string, input: string | undefined, attributeName: string = "DefaultValue") {
44-
const element = getXmlElementValue(xml, elementName);
45-
46-
if (element) {
47-
try {
48-
xml[elementName][0].$[attributeName] = input;
49-
} catch (err) { console.error(`Unable to write value to xml attribute: ${err}`); }
50-
}
35+
xml[elementName][0].$[attributeName] = input;
5136
}

packages/office-addin-manifest/test/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ describe("Manifest", function() {
8484

8585
// verify displayName updated and guid not updated
8686
assert.notStrictEqual(originalInfo.displayName, updatedInfo.displayName);
87+
assert.strictEqual(updatedInfo.displayName, testDisplayName);
8788
assert.strictEqual(originalInfo.id, updatedInfo.id);
8889
});
8990
it("should handle not specifying either a guid or displayName", async function() {

0 commit comments

Comments
 (0)