Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Write content
let content = ' '
if (this._.useTimer) {
content += ` ${grey(this._.seconds + 's')}`
content += ` ${grey(figures.pointerSmall)}`
}
content += ` ${stage}`
content += ` ${grey(figures.pointerSmall)} ${this._.parentComponent}`
content += ` ${grey(figures.pointerSmall)} ${message}`
process.stdout.write(content)
// Put cursor to starting position for next view
console.log(os.EOL) // eslint-disable-line
process.stdout.write(ansiEscapes.cursorLeft)
process.stdout.write(ansiEscapes.cursorShow)
if (reason === 'error') {
process.exit(1)
} else {
process.exit(0)
}
}
// Write content
this.log()
let content = ''
if (this._.timer) {
content += `${grey(this._.timerSeconds + 's')}`
content += ` ${grey(figures.pointerSmall)} `
}
content += `${this._.entity} `
content += `${grey(figures.pointerSmall)} ${message}`
process.stdout.write(content)
// Put cursor to starting position for next view
console.log(os.EOL) // eslint-disable-line
process.stdout.write(ansiEscapes.cursorLeft)
process.stdout.write(ansiEscapes.cursorShow)
if (reason === 'error') {
process.exit(1)
} else {
process.exit(0)
}
}
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);
}
function onexit (options) {
const ansi = require('ansi-escapes')
process.stderr.write(ansi.cursorShow)
if (options.exit) process.exit(1)
}
const showCursor = () =>
process.stdout.write(ansi.cursorShow)
process.once('exit', () => {
if (process.stderr.isTTY) {
process.stderr.write(ansi.cursorShow)
}
})
return c.run(ctx)
finish() {
stdout(ansiEscapes.cursorShow);
},
},
function done () {
render()
bar.complete = true
stderr.write('\n')
stderr.write(ansi.cursorShow)
}
function stop () {
if (!options.hide) {
stderr.write(
ansi.cursorHide +
ansi.cursorLeft +
options.prompt +
input.replace(/./g, '*') +
'\n' +
ansi.cursorShow)
} else {
stderr.write('\n')
}
stdin.removeListener('data', fn)
stdin.setRawMode(false)
stdin.pause()
}