1
0
mirror of https://github.com/actions/labeler synced 2026-05-10 12:51:03 +02:00
This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -1,7 +1,7 @@
const color = require('kleur');
const Prompt = require('./prompt');
const { cursor } = require('sisteransi');
const { style, clear, strip, figures } = require('../util');
const { erase, cursor } = require('sisteransi');
const { style, clear, lines, figures } = require('../util');
/**
* TextPrompt Base Element
@@ -154,36 +154,27 @@ class TextPrompt extends Prompt {
render() {
if (this.closed) return;
if (!this.firstRender) {
if (this.outputError)
this.out.write(cursor.down(lines(this.outputError) - 1) + clear(this.outputError));
this.out.write(clear(this.outputText));
}
super.render();
let erase = (this.lines ? cursor.down(this.lines) : ``)+this.clear;
this.lines = 0;
this.outputError = '';
let prompt = [
this.outputText = [
style.symbol(this.done, this.aborted),
color.bold(this.msg),
style.delimiter(this.done),
this.red ? color.red(this.rendered) : this.rendered
].join(` `);
let error = ``;
if (this.error) {
let lines = this.errorMsg.split(`\n`);
error += lines.reduce((a, l, i) => a += `\n${i ? ' ' : figures.pointerSmall} ${color.red().italic(l)}`, ``);
this.lines = lines.length;
this.outputError += this.errorMsg.split(`\n`)
.reduce((a, l, i) => a + `\n${i ? ' ' : figures.pointerSmall} ${color.red().italic(l)}`, ``);
}
let position = ``;
if (this.lines) {
position += cursor.up(this.lines);
position += cursor.left+cursor.to(strip(prompt).length);
}
position += cursor.move(this.placeholder ?
-this.initial.length*this.scale :
-this.rendered.length+this.cursor*this.scale
);
this.out.write(erase+prompt+error+position);
this.clear = clear(prompt+error);
this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore);
}
}