salesforce-alm
Version:
This package contains tools, and APIs, for an improved salesforce.com developer experience.
34 lines (32 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fixExistingDollarSign = exports.standardOptions = exports.writeJSONasXML = void 0;
const fs = require("fs-extra");
const jsToXml = require("js2xmlparser");
const standardOptions = {
declaration: {
include: true,
encoding: 'UTF-8',
version: '1.0',
},
format: {
doubleQuotes: true,
},
};
exports.standardOptions = standardOptions;
const writeJSONasXML = async ({ path, json, type, options = standardOptions }) => {
const xml = jsToXml.parse(type, fixExistingDollarSign(json), options);
await fs.writeFile(path, xml);
};
exports.writeJSONasXML = writeJSONasXML;
const fixExistingDollarSign = (existing) => {
const existingCopy = { ...existing };
if (existingCopy.$) {
const temp = existingCopy.$;
delete existingCopy.$;
existingCopy['@'] = temp;
}
return existingCopy;
};
exports.fixExistingDollarSign = fixExistingDollarSign;
//# sourceMappingURL=jsonXmlTools.js.map