Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
argv.SID.forEach((sid) => {
const sub = db.find({ sid }); // bad use XD
if (!sub) {
print.error(l10n('CMD_LS_SID_NOT_FOUND', { sid }));
process.exit(1);
}
const { title, keywords, unkeywords, episodeParser } = sub;
const t = {};
t[l10n('CMD_LS_CELL_SID')] = sid;
t[l10n('CMD_LS_CELL_TITLE')] = title;
t[l10n('CMD_LS_CELL_KEYWORDS')] = keywords.join(', ');
t[l10n('CMD_LS_CELL_UNKEYWORDS')] = unkeywords.join(', ');
t[l10n('CMD_LS_CELL_EPISODEPARSER')] = `${episodeParser}`;
console.log(Table.print(t).trim());
console.log();
const tht = new Table();
sub.threads.forEach((th) => {
tht.cell(l10n('CMD_LS_CELL_THREAD_EPISODE'), th.episode.toString(TheEpisode.ascendCompare));
tht.cell(l10n('CMD_LS_CELL_THREAD_TITLE'), th.title);
tht.newRow();
});
console.log(tht.toString().trim());
console.log();
});
} else {
exports.formatRoutes = routes => { // eslint-disable-line
return Table.print(routes, ({ method, path }, cell) => {
for (const [attr, color, title] of [[method, 'green', 'METHOD'], [path, 'white', 'PATH']]) {
cell(style(title, 'cyan'), style(attr, color)); // eslint-disable-line
}
});
};
#!/usr/bin/env node
var fs = require('fs');
var child_process = require('child_process');
var Table = require('easy-table')
// add our own ".total()" method on the Table object
Table.prototype.totals = function(keys, label) {
keys = keys || Object.keys(this.columns);
label = label || 'Totals';
var totals = {};
var ii, jj, key;
for (ii in this.rows) {
var line = this.rows[ii];
for (jj in keys) {
key = keys[jj];
var val = line[key];
if (typeof val === 'number') {
totals[key] = (totals[key] || 0) + val;
}
}
}
// then totals
var first = true;
isOnSled = update.isBinded()
}
}
return [i, getUpdateType(type, id), id, isOnSled, ...updates]
})
).reduce((a, b, i) => {
i += start
let rider = engine.getRider(i)
let points = IDs.map((id) =>
rider.get(id).pos
).map(({x, y}) => [x, y])
.reduce((a, b) => [...a, ...b])
return [...a, ...b, [i, 'FrameEnd', '', rider.get('RIDER_MOUNTED').isBinded(), ...points]]
}, [])
let t = new Table()
t.separator = '│'
for (let row of data) {
row.forEach((cell, i) => {
let name
if (i < 4) {
name = names[i]
} else {
i -= 4
name = IDs[Math.floor(i / 2)].slice(0, 4)
name += i % 2 === 0 ? 'x' : 'y'
i += 4
}
t.cell(name, cell, i > 3 ? Table.number(2) : null)
})
t.newRow()
row.forEach((cell, i) => {
let name
if (i < 4) {
name = names[i]
} else {
i -= 4
name = IDs[Math.floor(i / 2)].slice(0, 4)
name += i % 2 === 0 ? 'x' : 'y'
i += 4
}
t.cell(name, cell, i > 3 ? Table.number(2) : null)
})
t.newRow()
_.each(options.table, function(item){ //flatten to an array without links
var exclude = ["links"]
if(_.isArray(options.excludes)){
exclude.push(options.excludes)
}
items.push(_.omit(item[options.key],exclude))
})
}else{
var exclude = ["links"]
if(_.isArray(options.excludes)){
exclude.push(options.excludes)
}
items.push(_.omit(options.table,exclude))
}
data = Table.print(items)
}
if(options.type == "success"){
return console.log("[", "3scale-cli".white, "]", msg.green, data);
}else if(options.type == "error"){
return console.log("[", "3scale-cli".white, "]", msg.red, data);
}else if(options.type == "info"){
}else{
return console.log("[", "3scale-cli".white, "]", msg.cyan, data);
}
} else {
throw new Error("no message defined to print!");
}
}
_.each(options.table, function(item){ //flatten to an array without links
var exclude = ["links"]
if(_.isArray(options.excludes)){
exclude.push(options.excludes)
}
items.push(_.omit(item[options.key],exclude))
})
}else{
var exclude = ["links"]
if(_.isArray(options.excludes)){
exclude.push(options.excludes)
}
items.push(_.omit(options.table,exclude))
}
data = Table.print(items)
}
if(options.type == "success"){
return console.log("[", "3scale-cli".white, "]", msg.green, data);
}else if(options.type == "error"){
return console.log("[", "3scale-cli".white, "]", msg.red, data);
}else if(options.type == "info"){
}else{
return console.log("[", "3scale-cli".white, "]", msg.cyan, data);
}
} else {
throw new Error("no message defined to print!");
}
}
async function text(headerValues: any, items: any) {
const rows: any[] = [];
_.each(items, (item) => {
const row = {};
_.each(headerValues, (headerValue) => {
row[headerValue] = item[headerValue];
});
rows.push(row);
});
console.log(easyTable.print(rows));
}
export default function configCmd () {
const table = new Table()
const keys = Object.keys(config)
for (const key of keys) {
const value = config[key]
table.cell('key', key)
table.cell('value', value)
table.newRow()
}
console.log(table.toString())
}
export default function configCmd () {
const table = new Table()
const keys = Object.keys(config)
for (let key of keys) {
const value = config[key]
table.cell('key', key)
table.cell('value', value)
table.newRow()
}
console.log(table.toString())
}