Comparing version 0.1.0 to 0.1.1
@@ -13,3 +13,3 @@ /** | ||
name: "toBeDelivered", | ||
message: "Hi, welcome to Node Pizza plaza. \r\n" + | ||
message: "Hi, welcome to Node Pizza plaza. \n" + | ||
"Is it for a delivery?" | ||
@@ -16,0 +16,0 @@ }, |
@@ -11,2 +11,3 @@ /** | ||
var EventEmitter = require("events").EventEmitter; | ||
var charm = require("charm")(); | ||
@@ -24,6 +25,6 @@ /** | ||
cli.prompts = { | ||
input: require("./prompts/input"), | ||
confirm: require("./prompts/confirm"), | ||
list: require("./prompts/list"), | ||
rawlist: require("./prompts/rawlist") | ||
list : "./prompts/list", | ||
input : "./prompts/input", | ||
confirm : "./prompts/confirm", | ||
rawlist : "./prompts/rawlist" | ||
}; | ||
@@ -45,6 +46,14 @@ | ||
// Propate current readline events to the global façade | ||
process.stdin.on("keypress", function(s, key) { | ||
rlVent.emit("keypress", s, key); | ||
}); | ||
charm.pipe(process.stdin); | ||
// Make sure questions is an array. | ||
if (!_.isArray(questions)) { | ||
questions = [questions]; | ||
} | ||
// Propagate current readline events to the global façade | ||
process.stdin | ||
.on("keypress", function(s, key) { | ||
rlVent.emit("keypress", s, key); | ||
}); | ||
rl | ||
@@ -56,3 +65,5 @@ .on("line", function() { | ||
.on("close", function() { | ||
console.log(); // Line return | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
rlVent.emit.apply(rlVent, ["close"].concat(args)); | ||
console.log("\n"); // Line return | ||
}); | ||
@@ -69,4 +80,3 @@ | ||
console.log(); // line return; | ||
console.log(); // line return; | ||
console.log("\n"); // line return; | ||
@@ -77,3 +87,4 @@ if (!self.prompts[question.type]) { | ||
var prompt = new self.prompts[question.type](question, rlVent); | ||
var Prompt = require(self.prompts[question.type]); | ||
var prompt = new Prompt(question, rlVent); | ||
prompt.run(after); | ||
@@ -83,4 +94,9 @@ }, | ||
function() { | ||
// Remove events | ||
rlVent.removeAllListeners(); | ||
rl.removeAllListeners(); | ||
process.stdin.removeAllListeners("keypress"); | ||
rl.close(); | ||
rlVent.removeAllListeners(); // just little memory leaks prevention | ||
charm.end(); | ||
if (_.isFunction(allDone)) { | ||
@@ -87,0 +103,0 @@ allDone(answers); |
@@ -58,3 +58,3 @@ /** | ||
this.height = message.split(/\r/).length; | ||
this.height = message.split(/\n/).length; | ||
@@ -61,0 +61,0 @@ return this; |
@@ -72,5 +72,5 @@ /** | ||
this.height = message.split(/\r/).length; | ||
this.height = message.split(/\n/).length; | ||
return this; | ||
}; |
@@ -11,2 +11,3 @@ /** | ||
/** | ||
@@ -74,3 +75,3 @@ * Module exports | ||
// Render question | ||
var message = this.message + "\r\n"; | ||
var message = this.message + "\n"; | ||
charm.write(message); | ||
@@ -82,3 +83,3 @@ | ||
(i !== self.selected) && charm.foreground("white"); | ||
charm.write(choice.name + "\r\n").foreground("white"); | ||
charm.write(choice.name + "\n").foreground("white"); | ||
self.height++; | ||
@@ -92,5 +93,5 @@ }); | ||
this.firstRender = false; | ||
this.height += message.split(/\r/).length; | ||
this.height += message.split(/\n/).length; | ||
return this; | ||
}; |
@@ -45,3 +45,3 @@ /** | ||
self.clean(1).render(); | ||
charm.write( input + "\r\n"); | ||
charm.write( input + "\n"); | ||
self.rl.removeAllListeners("line"); | ||
@@ -70,3 +70,3 @@ cb(self.choices[input - 1].value); | ||
// Render question | ||
var message = this.message + "\r\n"; | ||
var message = this.message + "\n"; | ||
charm.write(message); | ||
@@ -77,3 +77,3 @@ | ||
(i === self.selected) && charm.foreground("cyan"); | ||
charm.write(" " + (i + 1) + ") " + choice.name + "\r\n").foreground("white"); | ||
charm.write(" " + (i + 1) + ") " + choice.name + "\n").foreground("white"); | ||
self.height++; | ||
@@ -83,5 +83,5 @@ }); | ||
this.height += message.split(/\r/).length; | ||
this.height += message.split(/\n/).length; | ||
return this; | ||
}; |
{ | ||
"name": "inquirer", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A collection of common interactive command line user interfaces.", | ||
@@ -5,0 +5,0 @@ "main": "lib/inquirer.js", |
@@ -36,6 +36,6 @@ Inquirer.js [![Build Status](https://travis-ci.org/SBoudrias/Inquirer.js.png?branch=master)](http://travis-ci.org/SBoudrias/Inquirer.js) | ||
Checkout the `example/` folder for code and interface example. | ||
Checkout the `examples/` folder for code and interface examples. | ||
``` prompt | ||
node example/pizza.js | ||
node examples/pizza.js | ||
# etc | ||
@@ -42,0 +42,0 @@ ``` |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
80893
830
1