Comparing version 0.10.0 to 0.10.1
@@ -14,3 +14,5 @@ 'use strict'; | ||
if (!this.rl) { | ||
this.rl = readlineFacade.createInterface(opt); | ||
this.rl = readlineFacade.createInterface(_.extend({ | ||
terminal: true | ||
}, opt)); | ||
} | ||
@@ -20,3 +22,2 @@ this.rl.resume(); | ||
this.onForceClose = this.onForceClose.bind(this); | ||
this.onKeypress = this.onKeypress.bind(this); | ||
@@ -26,5 +27,2 @@ // Make sure new prompt start on a newline when closing | ||
process.on('exit', this.onForceClose); | ||
// Propagate keypress events directly on the readline | ||
this.rl.input.addListener('keypress', this.onKeypress); | ||
}; | ||
@@ -51,3 +49,2 @@ | ||
this.rl.removeListener('SIGINT', this.onForceClose); | ||
this.rl.input.removeListener('keypress', this.onKeypress); | ||
process.removeListener('exit', this.onForceClose); | ||
@@ -57,3 +54,2 @@ | ||
this.rl.output.unmute(); | ||
this.rl.output.write('\x1B[?25h'); // show cursor | ||
@@ -66,17 +62,1 @@ // Close the readline | ||
}; | ||
/** | ||
* Handle and propagate keypress events | ||
*/ | ||
UI.prototype.onKeypress = function (s, key) { | ||
// Ignore `enter` key (readline `line` event is the only one we care for) | ||
if (key && (key.name === 'enter' || key.name === 'return')) { | ||
return; | ||
} | ||
if (this.rl) { | ||
this.rl.emit( 'keypress', s, key ); | ||
} | ||
}; |
@@ -53,3 +53,3 @@ /** | ||
this.bottomBar = bottomBar; | ||
rlUtils.clearLine(this.rl); | ||
rlUtils.clearLine(this.rl, 1); | ||
return this.render(); | ||
@@ -65,3 +65,3 @@ }; | ||
Prompt.prototype.writeLog = function( data ) { | ||
rlUtils.clearLine(this.rl); | ||
rlUtils.clearLine(this.rl, 1); | ||
this.rl.output.write(this.enforceLF(data.toString())); | ||
@@ -68,0 +68,0 @@ return this.render(); |
@@ -5,7 +5,11 @@ 'use strict'; | ||
function normalizeKeypressEvents(value, key) { | ||
return { value: value, key: key }; | ||
return { value: value, key: key || {} }; | ||
} | ||
module.exports = function (rl) { | ||
var keypress = rx.Observable.fromEvent(rl, 'keypress', normalizeKeypressEvents); | ||
var keypress = rx.Observable.fromEvent(rl.input, 'keypress', normalizeKeypressEvents) | ||
.filter(function (e) { | ||
// Ignore `enter` key. On the readline, we only care about the `line` event. | ||
return e.key.name !== 'enter' && e.key.name !== 'return'; | ||
}); | ||
@@ -17,7 +21,7 @@ return { | ||
normalizedUpKey: keypress.filter(function (e) { | ||
return e.key && (e.key.name === 'up' || e.key.name === 'k'); | ||
return e.key.name === 'up' || e.key.name === 'k'; | ||
}).share(), | ||
normalizedDownKey: keypress.filter(function (e) { | ||
return e.key && (e.key.name === 'down' || e.key.name === 'j'); | ||
return e.key.name === 'down' || e.key.name === 'j'; | ||
}).share(), | ||
@@ -33,5 +37,4 @@ | ||
return e.key && e.key.name === 'space'; | ||
}).share(), | ||
}).share() | ||
}; | ||
}; |
{ | ||
"name": "inquirer", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "A collection of common interactive command line user interfaces.", | ||
@@ -5,0 +5,0 @@ "main": "lib/inquirer.js", |
@@ -68,3 +68,3 @@ Inquirer.js | ||
`list`, `rawlist`, `password` | ||
- **name**: (String) The name to use when storing the answer in the anwers hash. | ||
- **name**: (String) The name to use when storing the answer in the answers hash. | ||
- **message**: (String|Function) The question to print. If defined as a function, the first parameter will be the current inquirer session answers. | ||
@@ -78,3 +78,3 @@ - **default**: (String|Number|Array|Function) Default value(s) to use if nothing is entered, or a function that returns the default value(s). If defined as a function, the first parameter will be the current inquirer session answers. | ||
`default`(if defined as a function), `validate`, `filter` and `when` functions can be called asynchronously using `this.async()`. You just have to pass the value you'd normally return to the callback option. | ||
`default`, `choices`(if defined as functions), `validate`, `filter` and `when` functions can be called asynchronously using `this.async()`. You just have to pass the value you'd normally return to the callback option. | ||
@@ -124,3 +124,3 @@ ``` javascript | ||
Ask opening hours | ||
Talk to the receptionnist | ||
Talk to the receptionist | ||
``` | ||
@@ -175,3 +175,3 @@ | ||
Choices whose property `disabled` is truthy will be unselectable. If `disabled` is a string, then the string will be outputed next to the disabled choice, otherwise it'll default to `"Disabled"`. The `disabled` property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string. | ||
Choices whose property `disabled` is truthy will be unselectable. If `disabled` is a string, then the string will be outputted next to the disabled choice, otherwise it'll default to `"Disabled"`. The `disabled` property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string. | ||
@@ -178,0 +178,0 @@ ![Checkbox prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/checkbox-prompt.png) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62251
1688