Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private drawSinglePlugin = ( p: TestScriptPluginData ): void => {
const format = " - %-12s: %s"; // util.format does not support padding :(
this.write( 'Plugin ' + chalk.yellow( p.name ) );
this.write( sprintf( format, 'version', p.version ) );
this.write( sprintf( format, 'description', p.description ) );
this.write( sprintf( format, 'targets', p.targets.join( ', ' ) ) );
const authors = p.authors.map( ( a, idx ) => 0 === idx ? a : sprintf( '%-17s %s', '', a ) );
this.write( sprintf( format, 'authors', authors.join( '\n') ) );
this.write( sprintf( format, 'fake', p.isFake ? 'yes': 'no' ) );
this.write( sprintf( format, 'file', p.file ) );
this.write( sprintf( format, 'class', p.class ) );
};
if (rev) this.logger().debug(sprintf('RevisionService::collectRevisions: Saved revision %s (old note)', rev.id));
}
const rev = await this.createNoteRevision_(note);
if (rev) this.logger().debug(sprintf('RevisionService::collectRevisions: Saved revision %s (Last rev was more than %d ms ago)', rev.id, Setting.value('revisionService.intervalBetweenRevisions')));
doneNoteIds.push(noteId);
this.isOldNotesCache_[noteId] = false;
}
}
if (change.type === ItemChange.TYPE_DELETE && !!change.before_change_item) {
const note = JSON.parse(change.before_change_item);
const revExists = await Revision.revisionExists(BaseModel.TYPE_NOTE, note.id, note.updated_time);
if (!revExists) {
const rev = await this.createNoteRevision_(note);
if (rev) this.logger().debug(sprintf('RevisionService::collectRevisions: Saved revision %s (for deleted note)', rev.id));
}
doneNoteIds.push(noteId);
}
Setting.setValue('revisionService.lastProcessedChangeId', change.id);
}
}
} catch (error) {
if (error.code === 'revision_encrypted') {
// One or more revisions are encrypted - stop processing for now
// and these revisions will be processed next time the revision
// collector runs.
this.logger().info('RevisionService::collectRevisions: One or more revision was encrypted. Processing was stopped but will resume later when the revision is decrypted.', error);
} else {
this.logger().error('RevisionService::collectRevisions:', error);
}
if (Object.is(x, -0))
zero = "-" + zero;
return to_luastring(zero);
} else {
let buff = "";
let fe = frexp(x); /* 'x' fraction and exponent */
let m = fe[0];
let e = fe[1];
if (m < 0) { /* is number negative? */
buff += '-'; /* add signal */
m = -m; /* make it positive */
}
buff += "0x"; /* add "0x" */
buff += (m * (1<
humanSize: function(bytes) {
const isNumber = !isNaN(parseFloat(bytes)) && isFinite(bytes);
if (!isNumber) {
return '';
}
// Special case small numbers (including 0), because they're exact.
if (bytes < 1000) {
return sprintf.sprintf('%d', bytes);
}
let index = Math.floor(that.getBaseLog(bytes, 1000));
index = Math.min(that.units.length - 1, index);
return sprintf.sprintf('%.1f %s', bytes / Math.pow(1000, index), that.units[index]);
}
});
getDescription (assignment) {
const aux = assignment.aux ? assignment.aux : ''
assignment.description = sprintf(assignment.description, ...aux.split(','))
let description = assignment.description.split('\n')
return description.map((el, index) => (
<span>
{el}
<br>
</span>
))
}
var x = a.name;
var y = b.name;
return (x < y ? -1 : x > y ? 1 : 0);
});
list[i].items = byName;
}
var format = ' %-15s %-s';
if (repository) {
console.log(sprintf(format, 'Repository:', repository.name));
}
if (collection) {
console.log(sprintf(format, 'Collection:', collection.name));
}
if (channel) {
console.log(sprintf(format, 'Channel:', channel.name));
}
console.log(sprintf(format, 'Items:', ''));
var format2 = ' %-38s %-38s %-11s %-s';
console.log(sprintf(format2, 'Type', 'Id', 'Status', 'Name'));
for (var i = 0; i < list.length; i++) {
for (var j = 0; j < list[i].items.length; j++) {
var item = list[i].items[j];
var typeLabel = j === 0 ? item.type : '';
console.log(sprintf(format2, typeLabel, item.id, item.status, item.name));
}
}
};
const undeployRevision = function(name, rev){
if (conn.verbosity>0) {
utility.logWrite(sprintf('Undeploy %s %s r%s from env:%s', assetType, name, rev, env));
}
common.insureFreshToken(conn, function(requestOptions) {
requestOptions.url = urljoin(conn.urlBase,
'environments', env,
collection, name,
'revisions', rev,
'deployments');
if (conn.verbosity>0) {
utility.logWrite(sprintf('DELETE %s', requestOptions.url));
}
request.del(requestOptions, common.callback(conn, [200], cb));
});
};
if (rev) {
cols.forEach( col_spec => {
if(col_spec.is_numeric) {
col_spec.sum = floatVal(
api.column(col_index)
.data()
.map( v => floatVal(v) )
.reduce( (a, b) => a + b, 0 )
);
col_spec.pageSum = floatVal(
api.column(col_index, { page: 'current' })
.data()
.map( v => floatVal(v) )
.reduce( (a, b) => a + b, 0 )
);
$(api.column(col_index).footer()).html(
sprintf.sprintf('page=%s; all=%s',
col_spec.pageSum.toFixed(2),
col_spec.sum.toFixed(2))
);
}
col_index += 1;
});
}
common.insureFreshToken(conn, function(requestOptions) {
requestOptions.url = urljoin(conn.urlBase,
'environments', env,
collection, name,
'revisions', rev,
'deployments');
if (conn.verbosity>0) {
utility.logWrite(sprintf('DELETE %s', requestOptions.url));
}
request.del(requestOptions, common.callback(conn, [200], cb));
});
};
const formatFailureString = (config: PropertyDecoratorConfig, decoratorStr: string, className: string): string => {
const { decoratorName, errorMessage, propertyName } = config;
const decorators = arrayify(decoratorName)
.map(d => `"@${d}"`)
.join(', ');
return sprintf(errorMessage, decoratorStr, className, propertyName, decorators);
};