Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function objEquiv(a, b) {
if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
return false;
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
//~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem.
if (isArguments(a)) {
if (!isArguments(b)) {
return false;
}
a = pSlice.call(a);
b = pSlice.call(b);
return _deepEqual(a, b);
}
try {
var ka = shims.keys(a),
kb = shims.keys(b),
if (this.mCommandDefinition.experimental) {
helpText += this.grey(DefaultHelpGenerator.HELP_INDENT + "(experimental command)\n\n");
} else {
helpText += "\n\n";
}
}
// Only include global options by request and we're not producing markdown
includeGlobalOptions = includeGlobalOptions && !this.mProduceMarkdown;
// Print standard areas like description and usage
helpText += this.buildDescriptionSection();
helpText += this.buildUsageSection();
// Add positional arguments to the help text
if (!isNullOrUndefined(this.mCommandDefinition.positionals) &&
this.mCommandDefinition.positionals.length > 0) {
helpText += this.buildPositionalArgumentsSection();
}
// Add options to the help text
helpText += this.buildCommandOptionsSection();
if (includeGlobalOptions) {
helpText += this.buildGlobalOptionsSection();
}
// Build experimental description section and examples
helpText += this.getExperimentalCommandSection();
helpText += this.buildExamplesSection();
return helpText;
}
onCustomKeyValuePairSelected(): void {
this.resourceApiData.selectedValue = PropertiesDefinitionEnum.Custom;
if (isNullOrUndefined(this.resourceApiData.propertiesDefinition)) {
this.resourceApiData.propertiesDefinition = new PropertiesDefinition();
}
this.resourceApiData.propertiesDefinition.element = null;
this.resourceApiData.propertiesDefinition.type = null;
if (isNullOrUndefined(this.resourceApiData.propertiesDefinition)) {
this.resourceApiData.propertiesDefinition = new PropertiesDefinition();
}
this.resourceApiData.propertiesDefinition.element = null;
this.resourceApiData.propertiesDefinition.type = null;
if (isNullOrUndefined(this.resourceApiData.winerysPropertiesDefinition)) {
this.resourceApiData.winerysPropertiesDefinition = new WinerysPropertiesDefinition();
}
// The key/value pair list may be null
if (isNullOrUndefined(this.resourceApiData.winerysPropertiesDefinition.propertyDefinitionKVList)) {
this.resourceApiData.winerysPropertiesDefinition.propertyDefinitionKVList = [];
}
if (isNullOrUndefined(this.resourceApiData.winerysPropertiesDefinition.namespace)) {
this.resourceApiData.winerysPropertiesDefinition.namespace = this.sharedData.toscaComponent.namespace + '/propertiesdefinition/winery';
}
if (isNullOrUndefined(this.resourceApiData.winerysPropertiesDefinition.elementName)) {
this.resourceApiData.winerysPropertiesDefinition.elementName = 'properties';
}
this.activeElement = new SelectData();
this.activeElement.text = this.resourceApiData.winerysPropertiesDefinition.namespace;
private initializeTransUnits() {
if (isNullOrUndefined(this.transUnits)) {
this.transUnits = [];
let transUnitsInFile = this.xliffContent('trans-unit');
transUnitsInFile.each((index, transunit: CheerioElement) => {
let id = cheerio(transunit).attr('id');
if (!id) {
this._warnings.push(format('oops, trans-unit without "id" found in master, please check file %s', this.filename));
this._numberOfTransUnitsWithMissingId++;
}
this.transUnits.push(new TransUnit(transunit, id));
});
}
}
private getMustacheSummaryForOption(optionDefinition: ICommandOptionDefinition | ICommandPositionalDefinition,
isPositional: boolean = false): any {
let aliasString;
if (!isPositional) {
const def = optionDefinition as ICommandOptionDefinition;
aliasString = (!isNullOrUndefined(def.aliases) && def.aliases.length > 0) ?
"(" + def.aliases.map((alias: string) => {
return this.getDashFormOfOption(alias);
}).join(",") + ")" : "";
} else {
aliasString = "";
}
let longName: string;
if (isPositional) {
longName = CliUtils
.getPositionalSyntaxString(optionDefinition.required, optionDefinition.name);
} else {
longName = CliUtils.getDashFormOfOption(optionDefinition.name);
}
return {
long: longName,
aliases: aliasString,
public hasServiceLevel(): boolean {
return !isNullOrUndefined(this.serviceLevel);
}
getListOfTemplates(templateType: string): Array {
if (!isNullOrUndefined(this.topologyTemplate[templateType])) {
return this.topologyTemplate[templateType].map((template: WineryTemplate) => {
const newItem: SelectItem = new SelectItem('');
newItem.id = template.id;
newItem.text = template.id;
return newItem;
});
} else {
this.notify.warning('No ' + Utils.getToscaTypeNameFromToscaType(this.toscaType) + ' available.\nTo select a ' +
Utils.getToscaTypeNameFromToscaType(this.toscaType) +
' add at least one to the topology');
}
}
onAddClick() {
const formData: FormData = new FormData();
if (!isNullOrUndefined(this.file)) {
formData.append('file', this.file, this.file.name);
}
if (!isNull(this.selectedArtifactType)) {
formData.append('artifactType', this.selectedArtifactType);
}
if (!isNullOrUndefined(this.selectedNodeTypes)) {
for (const nodetype of this.selectedNodeTypes) {
formData.append('nodeTypes', nodetype);
}
}
if (!isNullOrUndefined(this.tagItems)) {
for (const tag of this.tagItems) {
formData.append('tags', tag);
}
} else {
formData.append('tags', '');
}
if (!isNullOrUndefined(this.selectedInfracstuctureNodeType)) {
formData.append('infrastructureNodeType', this.selectedInfracstuctureNodeType);
}
this.service.createTemplateFromArtifact(formData).subscribe(
data => this.notify.success('Service Template successfully created!'),
error => this.handleError(error)
);
private calculateTreeHeight(children = 0) {
let offset = 139;
let childrenCount = this.data.versionInstances.length - 1;
if (children > 0) {
childrenCount += children - 1;
offset = offset * 2 + 15;
}
if (!isNullOrUndefined(this.differences)) {
offset += 205;
}
this.treeHeight = (childrenCount * 126) + offset;
}
private static performBasicPositionalValidation(positionals: ICommandPositionalDefinition[], currentDefinitions: ICommandDefinition[]) {
for (const pos of positionals) {
/**
* All positionals must have a name
*/
if (isNullOrUndefined(pos.name) || pos.name.trim().length === 0) {
throw new ImperativeError({
msg: `A positional definition contains an undefined or empty name.`,
additionalDetails: "POSITIONAL_DEFINITION:\n" + JSON.stringify(pos) + "\nCURRENT_TREE:\n" + JSON.stringify(currentDefinitions)
});
}
/**
* All positionals must have a type
*/
if (isNullOrUndefined(pos.type) || pos.type.trim().length === 0) {
throw new ImperativeError({
msg: `A positional definition (${pos.name}) contains an undefined or empty type.`,
additionalDetails: "POSITIONAL_DEFINITION:\n" + JSON.stringify(pos) + "\nCURRENT_TREE:\n" + JSON.stringify(currentDefinitions)
});
}
/**
* All positionals must have a non-blank description
*/
if (isNullOrUndefined(pos.description) || pos.description.trim().length === 0) {
throw new ImperativeError({
msg: `A positional definition (${pos.name} of type ${pos.type}) contains an ` +
`undefined or empty description.`,
additionalDetails: "POSITIONAL_DEFINITION:\n" + JSON.stringify(pos) + "\nCURRENT_TREE:\n" + JSON.stringify(currentDefinitions)
});
}