Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const print = (data) => {
if (quiet || !data.trim()) return
const clearingLine = hasClearLineRef.test(data)
data = processOutput(data)
if (lastOutputFolder !== folder) {
if (lastOutputClearedLine) {
process.stdout.write(ansiEscapes.eraseLine)
process.stdout.write(ansiEscapes.cursorTo(0))
}
// Different folder => print folder tag
process.stdout.write(printTag)
if (clearingLine) {
process.stdout.write('\n')
}
}
process.stdout.write(data)
lastOutputClearedLine = clearingLine ? folder : false
lastOutputFolder = folder
}
clearLine() {
this.spinnerActivity.push(Buffer.from(ansiEscapes.eraseLine, 'ascii'));
}
const writeToHyperdrive = require('./lib/write-to-hyperdrive')
const FEED_VERSION = 2
const showError = (err) => {
console.error(err)
process.exit(1)
}
const dir = envPaths('p2p-wiki', {suffix: ''}).data
mkdirp.sync(dir)
const dbPath = path.join(dir, 'db')
let clear = '\n'
if (isatty(process.stderr.fd) && !isatty(process.stdout.fd)) {
clear = esc.eraseLine + esc.cursorTo(0)
}
const report = (slug, revId) => {
process.stderr.write(clear + slug + ' @ ' + revId)
}
let concurrency = process.env.CONCURRENCY
if (!concurrency || Number.isNaN(concurrency = parseInt(concurrency))) {
concurrency = 4
}
const db = hyperdrive(dbPath)
db.ready((err) => {
if (err) return showError(err)
const keyAsHex = db.key.toString('hex')
console.info(dbPath, keyAsHex)
return new Promise(function (resolve, reject) {
let stdin = process.stdin
let stderr = process.stderr
let input = ''
stdin.setEncoding('utf8')
stderr.write(ansi.eraseLine)
stderr.write(ansi.cursorLeft)
cli.console.writeError(options.prompt)
stdin.resume()
stdin.setRawMode(true)
function stop () {
if (!options.hide) {
stderr.write(
ansi.cursorHide +
ansi.cursorLeft +
options.prompt +
input.replace(/./g, '*') +
'\n' +
ansi.cursorShow)
} else {
stderr.write('\n')
return new Promise(function (resolve, reject) {
let stdin = process.stdin
let stderr = process.stderr
let input = ''
stdin.setEncoding('utf8')
stderr.write(ansi.eraseLine)
stderr.write(ansi.cursorLeft)
cli.console.writeError(options.prompt)
stdin.resume()
stdin.setRawMode(true)
function stop () {
if (!options.hide) {
stderr.write(
ansi.cursorHide +
ansi.cursorLeft +
options.prompt +
input.replace(/./g, '*') +
'\n' +
ansi.cursorShow)
} else {
stderr.write('\n')
_onChange(pattern: string, options: ScrollOptions) {
this._pipe.write(ansiEscapes.eraseLine);
this._pipe.write(ansiEscapes.cursorLeft);
}
}
function printSequence(index, stdout) {
index = (index < sequence.length - 1) ? index + 1 : 0;
const str = chalk.bold(sequence[index]);
stdout.write(ansiEscapes.eraseLine + ansiEscapes.cursorLeft);
stdout.write(str);
return index;
}
, render: function () {
process.stdout.write(esc.eraseLine + esc.cursorTo(0)
+ esc.cursorHide + [
ui.symbol(this.done, this.aborted)
, chalk.bold(this.msg), ui.delimiter(false)
, this.renderDigits(this.value, this.cursor, this.done)
].join(' '))
}
}
private clearLine(row: number): void {
this.printAt(ansiEscapes.eraseLine, { x: 0, y: row });
}