Comparing version 0.3.4 to 0.3.5
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /*jshint strict:false */ |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -142,5 +142,6 @@ /** | ||
Prompt.prototype.onKeypress = function( s, key ) { | ||
// Only process up, down, space and 1-9 key | ||
if ( key && (key.name !== "up" && key.name !== "down" && key.name !== "space") ) return; | ||
if ( key && key.name === "space" ) s = undefined; | ||
// Only process up, down, space, j, k and 1-9 keys | ||
var keyWhitelist = [ "up", "down", "space", "j", "k" ]; | ||
if ( key && !_.contains(keyWhitelist, key.name) ) return; | ||
if ( key && (key.name === "space" || key.name === "j" || key.name === "k") ) s = undefined; | ||
if ( s && "123456789".indexOf(s) < 0 ) return; | ||
@@ -160,5 +161,5 @@ | ||
this.opt.choices.getChoice(this.pointer).checked = !checked; | ||
} else if ( key && key.name === "up" ) { | ||
} else if ( key && (key.name === "up" || key.name === "k") ) { | ||
(this.pointer > 0) ? this.pointer-- : (this.pointer = len - 1); | ||
} else if ( key && key.name === "down" ) { | ||
} else if ( key && (key.name === "down" || key.name === "j") ) { | ||
(this.pointer < len - 1) ? this.pointer++ : (this.pointer = 0); | ||
@@ -165,0 +166,0 @@ } |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -134,4 +134,6 @@ /** | ||
Prompt.prototype.onKeypress = function( s, key ) { | ||
// Only process up, down and 1-9 key | ||
if ( key && (key.name !== "up" && key.name !== "down") ) return; | ||
// Only process up, down, j, k and 1-9 keys | ||
var keyWhitelist = [ "up", "down", "j", "k" ]; | ||
if ( key && !_.contains(keyWhitelist, key.name) ) return; | ||
if ( key && (key.name === "j" || key.name === "k") ) s = undefined; | ||
if ( s && "123456789".indexOf(s) < 0 ) return; | ||
@@ -142,5 +144,5 @@ | ||
var len = this.opt.choices.realLength; | ||
if ( key && key.name === "up" ) { | ||
if ( key && (key.name === "up" || key.name === "k") ) { | ||
(this.selected > 0) ? this.selected-- : (this.selected = len - 1); | ||
} else if ( key && key.name === "down" ) { | ||
} else if ( key && (key.name === "down" || key.name === "j") ) { | ||
(this.selected < len - 1) ? this.selected++ : (this.selected = 0); | ||
@@ -147,0 +149,0 @@ } else if ( Number(s) <= len ) { |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
{ | ||
"name": "inquirer", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "A collection of common interactive command line user interfaces.", | ||
@@ -5,0 +5,0 @@ "main": "lib/inquirer.js", |
@@ -0,0 +0,0 @@ Inquirer.js [![Build Status](https://travis-ci.org/SBoudrias/Inquirer.js.png?branch=master)](http://travis-ci.org/SBoudrias/Inquirer.js) |
@@ -0,0 +0,0 @@ var inquirer = require("../../lib/inquirer"); |
@@ -0,0 +0,0 @@ var EventEmitter = require("events").EventEmitter; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -84,2 +84,15 @@ var expect = require("chai").expect; | ||
it("should allow for vi-style navigation", function( done ) { | ||
this.checkbox.run(function( answer ) { | ||
expect(answer.length).to.equal(1); | ||
expect(answer[0]).to.equal("choice 2"); | ||
done(); | ||
}); | ||
this.rl.emit("keypress", "j", { name: "j" }); | ||
this.rl.emit("keypress", "j", { name: "j" }); | ||
this.rl.emit("keypress", "k", { name: "k" }); | ||
this.rl.emit("keypress", " ", { name: "space" }); | ||
this.rl.emit("line"); | ||
}); | ||
it("should allow 1-9 shortcut key", function( done ) { | ||
@@ -86,0 +99,0 @@ |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -45,3 +45,3 @@ var expect = require("chai").expect; | ||
it("should move selected cursor up and down on keypress", function( done ) { | ||
it("should allow for arrow navigation", function( done ) { | ||
@@ -58,2 +58,15 @@ this.list.run(function( answer ) { | ||
it("should allow for vi-style navigation", function( done ) { | ||
this.list.run(function( answer ) { | ||
expect(answer).to.equal("bar"); | ||
done(); | ||
}); | ||
this.rl.emit("keypress", "j", { name : "j" }); | ||
this.rl.emit("keypress", "j", { name : "j" }); | ||
this.rl.emit("keypress", "k", { name : "k" }); | ||
this.rl.emit("line"); | ||
}); | ||
it("should loop the choices when going out of boundaries", function( done ) { | ||
@@ -60,0 +73,0 @@ |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
@@ -0,0 +0,0 @@ var expect = require("chai").expect; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
150376
3190