Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const render = (opts, content = {}) => {
const { h, renderToString } = require('ink') // eslint-disable-line
const Table = require('ink-table').default
if (opts.json) {
console.log(JSON.stringify(content, null, 2))
} else if (opts.parseable) {
console.log(['collaborator', 'access'].join('\t'))
Object.keys(content).forEach(collab => {
console.log([collab, content[collab]].join('\t'))
})
} else if (!opts.silent && opts.loglevel !== 'silent') {
const data = Object.keys(content).map(collab => {
return { collab, role: content[collab] }
})
console.log(renderToString())
}
}
<table></table>
try {
const tokens = await libprofile.listTokens(opts)
if (opts.json) {
console.log(JSON.stringify(tokens, null, 2))
} else if (opts.parseable) {
console.log(tableHeaders.join('\t'))
tokens.forEach(token => {
let values = tableHeaders
.map(header => token[header])
.reduce((previous, current) => `${previous}\t${current}`)
console.log(values)
})
} else if (!opts.silent && opts.loglevel !== 'silent') {
const data = tokens.map(token => mapTokenToTable(token))
console.log(renderToString())
}
} catch (e) {
logError(e)
}
}
<table></table>
}))
const { rawSpec } = libnpm.parseArg(spec)
const options = {
packument,
fields,
spec: rawSpec && rawSpec !== '.' ? rawSpec : null,
json: opts.json
}
try {
const view = h(
fields.length ? PackageFields : PackageView,
options
)
console.log(renderToString(view))
} catch (e) {
opts.log.error('view', e.message)
opts.log.error('view', e.stack)
}
}
const value = key === 'tfa'
? parseTfaInfo(profileInfo[key])
: profileInfo[key]
if (value) {
console.log([key, value].join('\t'))
}
})
} else if (!opts.silent && opts.loglevel !== 'silent') {
profileInfo.tfa = parseTfaInfo(profileInfo.tfa)
const profileTableData = Object.keys(profileInfo).map(k => ({
key: k,
value: profileInfo[k]
}))
console.log(renderToString())
}
} catch (e) {
logError(e)
}
}
<table></table>
async function orgLs (argv, opts) {
opts = OrgConfig(opts)
const roster = await orgs.ls(opts.org, opts)
if (opts.json) {
console.log(JSON.stringify(roster, null, 2))
} else if (opts.parseable) {
console.log(['user', 'role'].join('\t'))
Object.keys(roster).forEach(user => {
console.log([user, roster[user]].join('\t'))
})
} else if (!opts.silent && opts.loglevel !== 'silent') {
const data = Object.keys(roster).map(user => {
return {user, role: roster[user]}
})
console.log(renderToString())
}
}
<table></table>
argv['read-only'],
argv.cidr_whitelist,
opts
))
if (opts.json) {
console.log(JSON.stringify(newToken, null, 2))
} else if (opts.parseable) {
console.log(tableHeaders.join('\t'))
let values = tableHeaders
.map(header => newToken[header])
.reduce((previous, current) => `${previous}\t${current}`)
console.log(values)
} else if (!opts.silent && opts.loglevel !== 'silent') {
const data = [mapTokenToTable(newToken, { trimToken: false })]
console.log(renderToString())
}
}
<table></table>
const maxLength = Math.max(...this.props.children.map(option => renderToString(option).length));
getSpacing(option) {
return '\u00A0'.repeat(this.state.maxLength - renderToString(option).length + this.props.padding);
}