From 2db95d9fecc1b99fceb04ab9385c186a64667318 Mon Sep 17 00:00:00 2001 From: benjaminJ Date: Wed, 28 Dec 2016 14:55:19 +0100 Subject: [PATCH 1/4] Fix some key maps issues - Fix cannot use `k`and `j`in search mode - Fix cannit use `-`in search mode --- src/index.js | 23 ++++++++++++----------- test/spec/index.spec.js | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/index.js b/src/index.js index 455664f..910d869 100644 --- a/src/index.js +++ b/src/index.js @@ -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); diff --git a/test/spec/index.spec.js b/test/spec/index.spec.js index 438fb46..9040c7a 100644 --- a/test/spec/index.spec.js +++ b/test/spec/index.spec.js @@ -137,6 +137,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"); From 61ce2d7655732d6ef94bd9ff1d689512c1e56121 Mon Sep 17 00:00:00 2001 From: benjaminJ Date: Wed, 28 Dec 2016 15:00:19 +0100 Subject: [PATCH 2/4] Dependencies updates --- .travis.yml | 2 +- appveyor.yml | 2 +- package.json | 24 ++++++++++++------------ test/spec/index.spec.js | 10 ++++------ 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4b1276..8ea9c4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "0.12" - "4" - "5" - "6" + - "7" diff --git a/appveyor.yml b/appveyor.yml index eabccb9..e0c06d9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,10 +1,10 @@ # Test against this version of Node.js environment: matrix: - - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "5" - nodejs_version: "6" + - nodejs_version: "7" # Install scripts. (runs after repo cloning) install: # Get the latest stable version of Node.js or io.js diff --git a/package.json b/package.json index 6570e65..5e365df 100644 --- a/package.json +++ b/package.json @@ -24,19 +24,19 @@ }, "homepage": "https://github.com/KamiKillertO/inquirer-select-directory#readme", "dependencies": { - "chalk": "^1.1.1", - "cli-cursor": "^1.0.2", - "figures": "^1.4.0", - "inquirer": "^1.1.2", - "rx-lite": "^4.0.8", - "util": "^0.10.3" + "chalk": "1.1.1", + "cli-cursor": "1.0.2", + "figures": "2.0.0", + "inquirer": "2.0.0", + "rx-lite": "4.0.8", + "util": "0.10.3" }, "devDependencies": { - "lodash": "^3.10.1", - "chai": "^3.4.1", - "events": "^1.1.0", - "mocha": "^2.3.4", - "mock-fs": "^3.11.0", - "sinon": "^1.17.2" + "lodash": "4.17.3", + "chai": "3.4.1", + "events": "1.1.0", + "mocha": "3.2.0", + "mock-fs": "3.12.1", + "sinon": "1.17.2" } } diff --git a/test/spec/index.spec.js b/test/spec/index.spec.js index 9040c7a..1ca221a 100644 --- a/test/spec/index.spec.js +++ b/test/spec/index.spec.js @@ -5,6 +5,7 @@ var mock = require("mock-fs"); var ReadlineStub = require("../helpers/readline"); var Prompt = require("../../src/index"); var path = require("path"); +var figures = require("figures"); describe("inquirer-directory", function() { @@ -113,16 +114,13 @@ describe("inquirer-directory", function() { this.prompt.run(); expect(this.rl.output.__raw__).to.not.contain("Search:"); this.rl.keyPress("/"); - var raw = this.rl.output.__raw__.replace("❯", ">"); - expect(raw).to.not.contain("> folder1"); + expect(this.rl.output.__raw__).to.not.contain(figures.pointer + " folder1"); expect(this.rl.output.__raw__).to.contain("Search:"); this.rl.keyPress("f"); - raw = this.rl.output.__raw__.replace("❯", ">"); - expect(raw).to.have.string("> folder1"); + expect(this.rl.output.__raw__).to.have.string(figures.pointer + " folder1"); this.rl.sendWord("older2"); - raw = this.rl.output.__raw__.replace("❯", ">"); - expect(raw).to.contain("> folder2"); + expect(this.rl.output.__raw__).to.contain(figures.pointer + " folder2"); }); it("should allow users to select a folder using 'choose this directory' choice", function() { From e514b5d01fcf60a3c29a7baae618e6c0c621a476 Mon Sep 17 00:00:00 2001 From: benjaminJ Date: Wed, 28 Dec 2016 15:04:07 +0100 Subject: [PATCH 3/4] Reduce code style issues --- .jshintrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.jshintrc b/.jshintrc index d081739..cef2901 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,4 +1,7 @@ { + "predef": [ + "it" + ], "devel": true, "esversion": 6, "strict": "global", From 07199bd5ea69ae9ba7a22bcbb24f448ebd4699bf Mon Sep 17 00:00:00 2001 From: benjaminJ Date: Wed, 28 Dec 2016 15:15:20 +0100 Subject: [PATCH 4/4] Version update --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 435a31d..6cf5537 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This project is a fork of [Inquirer-directory](https://github.com/nicksrandall/i ![](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&utm_medium=referral&utm_content=KamiKillertO/inquirer-select-directory&utm_campaign=Badge_Grade) diff --git a/package.json b/package.json index 5e365df..912ecb8 100644 --- a/package.json +++ b/package.json @@ -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": {