Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
// No point in generating when there are no files
if ( !files.length ) {
return resolve();
}
// Initialize DOM/XML/SVGO
const DOMParser = new xmldom.DOMParser();
const XMLSerializer = new xmldom.XMLSerializer();
const XMLDoc = new xmldom.DOMImplementation().createDocument(null, null, null);
const SVGOptimizer = new svgo(merge(options.output.svgo, {
plugins: [
// Prevent empty var:* attributes from getting removed prematurely
{ removeEmptyAttrs: false },
// Prevent groups from getting optimized prematurely as they may contain var:* attributes
{ moveGroupAttrsToElems: false },
{ collapseGroups: false },
// Prevent titles from getting removed prematurely
{ removeTitle: false }
]
}));
// Create SVG element
const svg = XMLDoc.createElement('svg');
export function createSVGDoc(): { DOCUMENT: Document; svgEl: SVGSVGElement } {
LOGGER.debug(`in create svg doc`);
const DOM = new DOMImplementation();
const doctype = DOM.createDocumentType(
'svg',
'-//W3C//DTD SVG 1.1//EN',
'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'
);
const SVG_NS = 'http://www.w3.org/2000/svg';
// Create an SVG Document and set its doctype
const DOCUMENT = DOM.createDocument(SVG_NS, 'svg', doctype);
// Create SVG element
const svgEl = DOCUMENT.createElementNS(SVG_NS, 'svg');
svgEl.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
svgEl.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
svgEl.setAttribute('version', '1.1');
// Add <svg> element to SVG Document
DOCUMENT.appendChild(svgEl);
LOGGER.debug(`creating svg document ${DOCUMENT}`);</svg>
view: ''
},
format: {
type: 'data',
publicPath: ''
},
variables: {
sprites: 'sprites',
variables: 'variables',
sizes: 'sizes',
mixin: 'sprite'
}
}, options);
const XMLSerializer = new xmldom.XMLSerializer();
const XMLDoc = new xmldom.DOMImplementation().createDocument(null, null, null);
const output = symbols.reduce((accumulator, symbol) => {
const svg = XMLDoc.createElement('svg');
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
svg.setAttribute('viewBox', symbol.getAttribute('viewBox'));
// Clone symbol contents to svg
Array.from(symbol.childNodes).forEach((childNode) => {
if ( ['title'].includes(childNode.nodeName.toLowerCase()) ) {
return;
}
svg.appendChild(childNode);
});
const sprite = XMLSerializer.serializeToString(svg);
module.exports = (symbols = [], options = {}) => {
options = merge({
prefix: '',
postfix: {
symbol: '',
view: ''
},
format: {
type: 'data',
publicPath: ''
}
}, options);
const XMLSerializer = new xmldom.XMLSerializer();
const XMLDoc = new xmldom.DOMImplementation().createDocument(null, null, null);
const sprites = symbols.map((symbol) => {
const svg = XMLDoc.createElement('svg');
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
svg.setAttribute('viewBox', symbol.getAttribute('viewBox'));
// Clone symbol contents to svg
Array.from(symbol.childNodes).forEach((childNode) => {
if ( ['title'].includes(childNode.nodeName.toLowerCase()) ) {
return;
}
svg.appendChild(childNode);
});
const selector = symbol.getAttribute('id').replace(options.postfix.symbol, '');
summaryDisplay() {
var doc = new XmlDom.DOMImplementation().createDocument('', 'testsuite');
var rootNode = doc.documentElement;
rootNode.setAttribute('name', 'Testem Tests');
rootNode.setAttribute('tests', this.total);
rootNode.setAttribute('skipped', this.skipped);
rootNode.setAttribute('failures', this.failures());
rootNode.setAttribute('timestamp', new Date());
rootNode.setAttribute('time', this.duration());
for (var i = 0, len = this.results.length; i < len; i++) {
var testcaseNode = this.getTestResultNode(doc, this.results[i]);
rootNode.appendChild(testcaseNode);
}
return doc.documentElement.toString();
}
_buildXml(changesetId) {
const xml = new DOMImplementation().createDocument('', '', null);
const osmElement = xml.createElement('osm');
const parentElement = xml.createElement(this._element.type);
delete this._element.attributes.user;
this._element.attributes.changeset = changesetId;
for (const key in this._element.attributes) {
if ({}.hasOwnProperty.call(this._element.attributes, key)) {
parentElement.setAttribute(key, this._element.attributes[key]);
}
}
for (const tag of this._element.tags) {
const tagElement = xml.createElement('tag');
import Q = require('q');
import tl = require('vsts-task-lib/task');
import fs = require('fs');
var utility = require ('./utility.js');
var xmldom = require('xmldom');
var serializer = new xmldom.XMLSerializer;
var implementation = new xmldom.DOMImplementation;
export async function substituteAppSettingsVariables(folderPath) {
var configFiles = tl.glob(folderPath + "/**/*config");
var tags = ["applicationSettings", "appSettings", "connectionStrings", "configSections"];
for(var index in configFiles) {
await substituteXmlVariables(configFiles[index], tags);
}
}
async function substituteXmlVariables(configFile, tags){
if(!tl.exist(configFile)) {
throw new Error(tl.loc("Configfiledoesntexists", configFile));
}
if( !tl.stats(configFile).isFile()) {
return;
}
_buildChangesetXml() {
const xml = new DOMImplementation().createDocument('', '', null);
const osmElement = xml.createElement('osm');
const changesetElement = xml.createElement('changeset');
const createdByElement = xml.createElement('tag');
const commentElement = xml.createElement('tag');
createdByElement.setAttribute('k', 'created_by');
createdByElement.setAttribute('v', this._changesetCreatedBy);
changesetElement.appendChild(createdByElement);
commentElement.setAttribute('k', 'comment');
commentElement.setAttribute('v', this._changesetComment);
changesetElement.appendChild(commentElement);
osmElement.appendChild(changesetElement);
xml.appendChild(osmElement);
summaryDisplay() {
const doc = new XmlDom.DOMImplementation().createDocument('', 'testsuite');
const rootNode = doc.documentElement;
rootNode.setAttribute('name', 'Testem Tests');
rootNode.setAttribute('tests', this.total);
rootNode.setAttribute('skipped', this.skipped);
rootNode.setAttribute('failures', this.failures());
rootNode.setAttribute('timestamp', new Date());
rootNode.setAttribute('time', this.duration());
for (let i = 0, len = this.results.length; i < len; i += 1) {
const testcaseNode = this.getTestResultNode(doc, this.results[i]);
rootNode.appendChild(testcaseNode);
}
return doc.documentElement.toString();
},
display() {
var _ = require( "lodash" );
var sql = require( "mssql" );
var xmldom = require( "xmldom" );
var domImplementation = new xmldom.DOMImplementation();
var xmlSerializer = new xmldom.XMLSerializer();
var buildTableVariableSql = require( "./build-table-variable-sql" );
var xmldom = require( "xmldom" );
function toXml( values, schema ) {
var doc = domImplementation.createDocument();
var keys = _.keys( schema );
var root = values.map( function( obj ) {
return keys.reduce( function( row, key ) {
var value = obj[ key ];
if ( value !== null && value !== undefined ) {
row.setAttribute( key, _.isDate( value ) ? value.toISOString() : value );
}
return row;
}, doc.createElement( "row" ) );