Skip to content

Commit

Permalink
Merged release/v1.0.2 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
KamiKillertO committed Dec 28, 2016
2 parents 8ed2521 + 07199bd commit c0f75c8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"predef": [
"it"
],
"devel": true,
"esversion": 6,
"strict": "global",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This project is a fork of [Inquirer-directory](https://github.com/nicksrandall/i

<!--[![Issue Count](https://codeclimate.com/github/KamiKillertO/inquirer-select-directory/badges/issue_count.svg)](https://codeclimate.com/github/KamiKillertO/inquirer-select-directory)!-->
![](https://img.shields.io/badge/license-MIT-blue.svg)
[![](https://img.shields.io/badge/release-v1.0.1-blue.svg)](https://github.com/KamiKillertO/inquirer-select-directory/releases/tag/v1.0.1)
[![](https://img.shields.io/badge/release-v1.0.2-blue.svg)](https://github.com/KamiKillertO/inquirer-select-directory/releases/tag/v1.0.2)
[![Build Status](https://travis-ci.org/KamiKillertO/inquirer-select-directory.svg)](https://travis-ci.org/KamiKillertO/inquirer-select-directory)
[![Build status](https://ci.appveyor.com/api/projects/status/fdyk5g3y56381742?svg=true)](https://ci.appveyor.com/project/KamiKillertO/inquirer-select-directory)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e6a963539c4440b69356649c0048ea30)](https://www.codacy.com/app/kamikillerto/inquirer-select-directory?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=KamiKillertO/inquirer-select-directory&amp;utm_campaign=Badge_Grade)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inquirer-select-directory",
"version": "1.0.1",
"version": "1.0.2",
"description": "A directory prompt for Inquirer.js",
"main": "src/index.js",
"scripts": {
Expand Down
23 changes: 12 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,22 @@ Prompt.prototype._run = function(callback) {
var alphaNumericRegex = /\w|\.|\-/i;
var events = observe(this.rl);


var keyUps = events.keypress.filter(function(evt) {
return evt.key.name === 'up' || (!self.searchMode && evt.key.name === 'k');
}).share();
return evt.key.name === 'up';
}).share();

var keyDowns = events.keypress.filter(function(evt) {
return evt.key.name === 'down' || (!self.searchMode && evt.key.name === 'j');
}).share();
var keyDowns = events.keypress.filter(function(evt) {
return evt.key.name === 'down';
}).share();

var keySlash = events.keypress.filter(function(evt) {
return evt.value === '/';
}).share();
var keySlash = events.keypress.filter(function(evt) {
return evt.value === '/' && !self.searchMode;
}).share();

var keyMinus = events.keypress.filter(function(evt) {
return evt.value === '-';
}).share();
var keyMinus = events.keypress.filter(function(evt) {
return evt.value === '-' && !self.searchMode;
}).share();

var alphaNumeric = events.keypress.filter(function(evt) {
return evt.key.name === 'backspace' || alphaNumericRegex.test(evt.value);
Expand Down
16 changes: 16 additions & 0 deletions test/spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ describe("inquirer-directory", function() {
this.rl.enter();
expect(this.prompt.currentPath.split(/\/|\\|\\\\/).slice(-1)[0]).to.equal("root");
});

it('should not go back using "-" in searchMode', function() {
this.prompt.run();
this.rl.keyPress("/");
this.rl.keyPress("-");
expect(this.prompt.currentPath.split(/\/|\\|\\\\/).slice(-1)[0]).to.equal("root");
});

it('allow only one search instance at the time', function() {
this.prompt.run();
this.rl.keyPress("/");
this.rl.keyPress("a");
this.rl.keyPress("/");
this.rl.keyPress("b");
expect(this.rl.output.__raw__).to.contain("Search: ab");
});
// it("should allow users to press keys to shortcut to that value", function (done) {
// prompt.run(function (answer) {
// expect(answer).to.equal("zfolder2");
Expand Down

0 comments on commit c0f75c8

Please sign in to comment.