Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
global.usejsdom = (doc) => {
// Switch document to jsdom
const jdom = new JSDOM(new XMLSerializer().serializeToString(doc), {contentType: 'text/xml'})
return jdom.window.document
}
const prjSettings = getDict(xml, "PROJECT_SETTINGS");
if (!prjSettings) {
throw new Error(`Cannot get PROJECT_SETTINGS from ${file}`);
}
const pkgName = getDict(prjSettings, "NAME");
if (!pkgName) {
throw new Error(`Cannot get NAME from ${file}`);
}
const name = `fortify-mac-x64-v${version.replace(/\./g, "_")}`;
pkgName.textContent = name;
// TODO: Set PATH to Fortify.app
process.stdout.write(`Rewrite ${file} file\n`);
fs.writeFileSync(file, new xmldom.XMLSerializer().serializeToString(xml));
}
}
versionNode.textContent = libraryVersion;
// update anuglar version
let angularVersionNode: any = query(
'/nuget:package/nuget:metadata/nuget:dependencies/nuget:dependency[@id=\'AngularJS.Core\']',
packageManifest,
true);
angularVersionNode.setAttribute('version', deps.angularLib);
// update fabric version
let fabricVersionNode: any = query(
'/nuget:package/nuget:metadata/nuget:dependencies/nuget:dependency[@id=\'OfficeUIFabric\']',
packageManifest,
true);
fabricVersionNode.setAttribute('version', deps.officeUiFabricLib);
// save file changes
let domSerialzer: XMLSerializer = new xmldom.XMLSerializer();
fs.writeFileSync(yargs.argv[argKeys.pkg] + '/src/ng-office-ui-fabric.nuspec', domSerialzer.serializeToString(packageManifest));
// create a new feature collection parent object
function fc() {
return {
type: 'FeatureCollection',
features: []
};
}
var serializer;
if (typeof XMLSerializer !== 'undefined') {
/* istanbul ignore next */
serializer = new XMLSerializer();
// only require xmldom in a node environment
} else if (typeof exports === 'object' && typeof process === 'object' && !process.browser) {
serializer = new (require('xmldom').XMLSerializer)();
}
function xml2str(str) {
// IE9 will create a new XMLSerializer but it'll crash immediately.
// This line is ignored because we don't run coverage tests in IE9
/* istanbul ignore next */
if (str.xml !== undefined) return str.xml;
return serializer.serializeToString(str);
}
var t = {
kml: function(doc) {
var gj = fc(),
// styleindex keeps track of hashed styles in order to match features
styleIndex = {},
// atomic geospatial types supported by KML - MultiGeometry is
source: xmlString,
result: String,
props: {
indent: 'yes'
}
}
xslt4node.transform(config, (err, result) => {
if (err) {
console.log('ERROR:', err)
}
result = header + result + footer
writeMenuFile(result)
})
}
leo.transformLeoXML(xml, 'L1', DOMParser, xslt4node, XMLSerializer)
.then(data => writeFiles(data))
function writeFiles(data) {
const textItems = data.textItems
_.each(textItems, (v, k) => {
v = util.formatText(v)
v = header + v + footer
let filename = k + '.html'
fs.writeFileSync('dist/static/site/' + filename, v)
})
process.exit(0)
}
function writeMenuFile(data) {
fs.writeFileSync('dist/static/site/index.html', data)
}
.append('circle')
.attr({ r: '10px', 'cx': moveX, 'cy': moveY });
gnode.append('text')
.classed('nodeTextShadow', true)
.attr('transform', function(d) { return 'translate(' + (moveX(d) + 12) + ',' + (moveY(d) - 8) + ')'; })
.text(pick('name'));
gnode.append('text')
.classed('nodeTex', true)
.attr('transform', function(d) { return 'translate(' + (moveX(d) + 12) + ',' + (moveY(d) - 8) + ')'; })
.text(pick('name'));
});
var svgXML = (new xmldom.XMLSerializer()).serializeToString(el);
if(config.format === 'svg'){
res.setHeader('Content-Type', 'image/svg+xml');
res.send('' + svgXML);
} else {
try {
var phantom = require('phantom');
var atob = require('atob');
var tmp = require('temporary');
var file = new tmp.File({
generator : function() {
}
});
file.renameSync('' + Date.now() + Math.random() + '.png');
console.log(file.path);
const serialize = dom =>
new XMLSerializer().serializeToString(dom, false, node => {
if (node.nodeType === NodeType.TEXT_NODE) {
if (regExWhitespace.test(node.data)) return null;
const data = node.data
.split(/\r|\r\n|\n/g)
.filter(s => /\S+/.test(s))
.map(s => s.replace(/^\s+/g, ''))
.join(os.EOL);
return node.ownerDocument.createTextNode(data);
}
return node;
});
this.prepareStyles = function(files) {
var self = this;
var style = this._styles;
var serializer = new XMLSerializer();
files.forEach(function(zip, index) {
var xmlString = zip.file("word/styles.xml").asText();
var xml = new DOMParser().parseFromString(xmlString, 'text/xml');
var nodes = xml.getElementsByTagName('w:style');
for (var node in nodes) {
if (/^\d+$/.test(node) && nodes[node].getAttribute) {
var styleId = nodes[node].getAttribute('w:styleId');
nodes[node].setAttribute('w:styleId', styleId + '_' + index);
var basedonStyle = nodes[node].getElementsByTagName('w:basedOn')[0];
if (basedonStyle) {
var basedonStyleId = basedonStyle.getAttribute('w:val');
basedonStyle.setAttribute('w:val', basedonStyleId + '_' + index);
}
if (modules.length == 0)
{
var pn = doc.createElement('modules');
doc.documentElement.appendChild(pn);
doc.documentElement.appendChild(doc.createTextNode("\n"));
pna = pn;
}
else
{
pna = modules.item(0);
}
pna.appendChild(node);
pna.appendChild(doc.createTextNode("\n"));
var serializer = new XMLSerializer();
var newxml = serializer.serializeToString(doc);
fs.writeFileSync(tiapp,newxml,'utf-8');
logger.info("Installed '" + opts.id + "' module to "+tiapp);
}
}
}
element.appendChild(child);
}
}
} else if (input.component === 'image') {
element = myDoc.createElement('img');
element.setAttribute('src', input.url);
element.setAttribute('width', input.size.width);
element.setAttribute('height', input.size.height);
if (input.imageId) {
element.setAttribute('data-id', input.imageId);
}
myDoc.documentElement.appendChild(element);
}
}
return new XMLSerializer().serializeToString(myDoc);
}