1
0
mirror of https://github.com/actions/labeler synced 2026-05-10 18:01:01 +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

@@ -11,8 +11,7 @@ const Prompt = require('./prompt');
const _require = require('../util'),
style = _require.style,
clear = _require.clear,
figures = _require.figures,
strip = _require.strip;
figures = _require.figures;
const _require2 = require('sisteransi'),
erase = _require2.erase,
@@ -56,20 +55,19 @@ const dfltLocales = {
monthsShort: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(','),
weekdays: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'.split(','),
weekdaysShort: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(',')
/**
* DatePrompt Base Element
* @param {Object} opts Options
* @param {String} opts.message Message
* @param {Number} [opts.initial] Index of default value
* @param {String} [opts.mask] The format mask
* @param {object} [opts.locales] The date locales
* @param {String} [opts.error] The error message shown on invalid value
* @param {Function} [opts.validate] Function to validate the submitted value
* @param {Stream} [opts.stdin] The Readable stream to listen to
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
*/
};
/**
* DatePrompt Base Element
* @param {Object} opts Options
* @param {String} opts.message Message
* @param {Number} [opts.initial] Index of default value
* @param {String} [opts.mask] The format mask
* @param {object} [opts.locales] The date locales
* @param {String} [opts.error] The error message shown on invalid value
* @param {Function} [opts.validate] Function to validate the submitted value
* @param {Stream} [opts.stdin] The Readable stream to listen to
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
*/
class DatePrompt extends Prompt {
constructor(opts = {}) {
@@ -231,28 +229,16 @@ class DatePrompt extends Prompt {
render() {
if (this.closed) return;
if (this.firstRender) this.out.write(cursor.hide);else this.out.write(erase.lines(1));
super.render();
let clear = erase.line + (this.lines ? erase.down(this.lines) : '') + cursor.to(0);
this.lines = 0;
let error = '';
if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText));
super.render(); // Print prompt
this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), []).join('')].join(' '); // Print 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;
} // Print prompt
let prompt = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), []).join('')].join(' ');
let position = '';
if (this.lines) {
position += cursor.up(this.lines);
position += cursor.left + cursor.to(strip(prompt).length);
this.outputText += this.errorMsg.split('\n').reduce((a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
}
this.out.write(clear + prompt + error + position);
this.out.write(erase.line + cursor.to(0) + this.outputText);
}
}