Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function render() {
var size_host = 4
var size_meta = 4
var size_tag = 3
sortedmembers.forEach(function(m) {
size_host = Math.max(size_host, m.host.length)
size_meta = Math.max(size_meta, m.meta.length)
size_tag = Math.max(size_tag, m.tag.length)
})
var nm = sortedmembers.length
w(AE.clearScreen)
w(AE.cursorHide)
w(AE.cursorUp(nm + 2))
w(AE.eraseDown)
console.log(
head(
[
Pad('host', size_host),
Pad(2, 'a'),
Pad(2, 'r'),
Pad(2, 's'),
Pad(8, 'time'),
Pad('tag', size_tag),
Pad('meta', size_meta),
'id'
].join(' ')
customSummary: () => {
if (outDir != null) {
console.log(chalk.bold('Finished'), chalk.green('✔︎'));
}
else {
process.stdout.write(ansiEscapes.clearScreen);
process.stdout.write(initialMessage(port, []).join('\n'));
}
},
})),
run(onSuccess: Function, onCancel: Function, options?: { header: string }) {
this._pipe.write(ansiEscapes.cursorHide);
this._pipe.write(ansiEscapes.clearScreen);
if (options && options.header) {
this._pipe.write(`${options.header}\n`);
this._currentUsageRows = usageRows + options.header.split('\n').length;
} else {
this._currentUsageRows = usageRows;
}
this._pipe.write(usage(this._entityName));
this._pipe.write(ansiEscapes.cursorShow);
this._prompt.enter(this._onChange.bind(this), onSuccess, onCancel);
}
module.exports = () => {
process.stdout.write(ansiEscapes.clearScreen);
process.exit(0);
};
async run() {
try {
this._println(ansiEscapes.clearScreen);
const {
rules: ruleOverrides = [],
fix: fixOverride,
} = getConfigOverrides();
if (Object.keys(ruleOverrides).length) {
this._println(chalk.bold('Current rule overrides'));
Object.keys(ruleOverrides).forEach(name => {
const value = ruleOverrides[name];
this._println(
` ${name} ${chalk.dim.italic(`(${FROM_RULE_VALUES[value]})`)}`,
);
});
this._println();
}
render: function (first) {
if (first) this.out.write('\n'.repeat(height))
if (this.querying) return
let out = esc.clearScreen + esc.cursorTo(0, 0)
+ this.renderStatus() + '\n'
if (this.messages.length === 0) {
} else if (this.message) {
out += this.renderMessage()
} else {
out += this.renderMessages()
}
out += '\n' + this.renderBindings()
this.out.write(out + esc.cursorHide)
}
}
private clear() {
this.print(ansiEscapes.clearScreen);
}
});
const dataListeners = process.stdin.listeners("data");
dataListeners.forEach(listener => {
process.stdin.removeListener("data", listener);
});
process.stdout.write(ansiEscapes.clearScreen);
process.stdin.resume();
try {
await callback();
process.stdout.write(ansiEscapes.clearScreen);
} catch (err) {
process.stderr.write(err.message + "\n");
process.stderr.write(err.stack + "\n");
}
sigIntListeners.forEach(listener => {
process.on("SIGINT", listener);
});
dataListeners.forEach(listener => {
process.stdin.on("data", listener);
});
}
const ansiEscapes = require('ansi-escapes')
const ESC = '\u001B['
const escapeSeqReg = /[-/\\^$*+?.()|[\]{}]/g
exports.escapeAnsiEscapeSeq = (s) => {
return s.replace(escapeSeqReg, '\\$&')
}
const ansiEscapeSeqsReg = new RegExp([
ansiEscapes.clearScreen,
ansiEscapes.eraseLine,
ansiEscapes.eraseStartLine,
ansiEscapes.eraseEndLine,
`${ESC}0K`,
`${ESC}0J`,
...(genSeq(ansiEscapes.cursorTo, 0, 10)),
...(genSeq2(ansiEscapes.cursorTo, 0, 10, 0, 10)),
...(genSeq(ansiEscapes.cursorMove, -10, 10)),
...(genSeq2(ansiEscapes.cursorMove, -10, 10, -10, 10)),
...(genSeq(ansiEscapes.cursorUp, -10, 10)),
...(genSeq(ansiEscapes.cursorDown, -10, 10)),
...(genSeq(ansiEscapes.cursorForward, -10, 10)),
...(genSeq(ansiEscapes.cursorBackward, -10, 10)),
].map(e => `(${exports.escapeAnsiEscapeSeq(e)})`).join('|'), 'g')
exports.stripAnsiEscapeSeqs = (s) => s.replace(ansiEscapeSeqsReg, '')