mirror of
https://github.com/actions/labeler
synced 2026-05-10 22:01:01 +02:00
build
This commit is contained in:
32
node_modules/prompts/lib/elements/date.js
generated
vendored
32
node_modules/prompts/lib/elements/date.js
generated
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
const color = require('kleur');
|
||||
const Prompt = require('./prompt');
|
||||
const { style, clear, figures, strip } = require('../util');
|
||||
const { style, clear, figures } = require('../util');
|
||||
const { erase, cursor } = require('sisteransi');
|
||||
const { DatePart, Meridiem, Day, Hours, Milliseconds, Minutes, Month, Seconds, Year } = require('../dateparts');
|
||||
|
||||
@@ -26,6 +26,7 @@ const dfltLocales = {
|
||||
weekdaysShort: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(',')
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DatePrompt Base Element
|
||||
* @param {Object} opts Options
|
||||
@@ -108,7 +109,7 @@ class DatePrompt extends Prompt {
|
||||
this.out.write('\n');
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
||||
async validate() {
|
||||
let valid = await this.validator(this.value);
|
||||
if (typeof valid === 'string') {
|
||||
@@ -179,34 +180,25 @@ class DatePrompt extends Prompt {
|
||||
render() {
|
||||
if (this.closed) return;
|
||||
if (this.firstRender) this.out.write(cursor.hide);
|
||||
else this.out.write(erase.lines(1));
|
||||
else this.out.write(clear(this.outputText));
|
||||
super.render();
|
||||
let clear = erase.line + (this.lines ? erase.down(this.lines) : '') + cursor.to(0);
|
||||
this.lines = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Print prompt
|
||||
let 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('')
|
||||
].join(' ');
|
||||
|
||||
let position = '';
|
||||
if (this.lines) {
|
||||
position += cursor.up(this.lines);
|
||||
position += cursor.left+cursor.to(strip(prompt).length);
|
||||
|
||||
// Print error
|
||||
if (this.error) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user