update
This commit is contained in:
+5
-2
@@ -56,8 +56,11 @@ class Prompt {
|
||||
*/
|
||||
|
||||
run() {
|
||||
return new Promise((resolve) => {
|
||||
this._run((value) => resolve(value));
|
||||
return new Promise((resolve, reject) => {
|
||||
this._run(
|
||||
(value) => resolve(value),
|
||||
(error) => reject(error)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -15,6 +15,7 @@ var { map, takeUntil } = require('rxjs/operators');
|
||||
var Base = require('./base');
|
||||
var observe = require('../utils/events');
|
||||
var Paginator = require('../utils/paginator');
|
||||
var incrementListIndex = require('../utils/incrementListIndex');
|
||||
|
||||
class CheckboxPrompt extends Base {
|
||||
constructor(questions, rl, answers) {
|
||||
@@ -37,7 +38,8 @@ class CheckboxPrompt extends Base {
|
||||
// Make sure no default is set (so it won't be printed)
|
||||
this.opt.default = null;
|
||||
|
||||
this.paginator = new Paginator(this.screen);
|
||||
const shouldLoop = this.opt.loop === undefined ? true : this.opt.loop;
|
||||
this.paginator = new Paginator(this.screen, { isInfinite: shouldLoop });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,14 +172,12 @@ class CheckboxPrompt extends Base {
|
||||
}
|
||||
|
||||
onUpKey() {
|
||||
var len = this.opt.choices.realLength;
|
||||
this.pointer = this.pointer > 0 ? this.pointer - 1 : len - 1;
|
||||
this.pointer = incrementListIndex(this.pointer, 'up', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onDownKey() {
|
||||
var len = this.opt.choices.realLength;
|
||||
this.pointer = this.pointer < len - 1 ? this.pointer + 1 : 0;
|
||||
this.pointer = incrementListIndex(this.pointer, 'down', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -55,7 +55,7 @@ class PromptUI extends Base {
|
||||
}, this.answers)
|
||||
)
|
||||
.toPromise(Promise)
|
||||
.then(this.onCompletion.bind(this));
|
||||
.then(this.onCompletion.bind(this), this.onError.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,6 +68,11 @@ class PromptUI extends Base {
|
||||
return this.answers;
|
||||
}
|
||||
|
||||
onError(error) {
|
||||
this.close();
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
processQuestion(question) {
|
||||
question = _.clone(question);
|
||||
return defer(() => {
|
||||
|
||||
Reference in New Issue
Block a user