avil13-co 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ask.d.ts +1 -0
- package/dist/ask.js +8 -2
- package/package.json +1 -1
- package/src/ask.ts +12 -1
package/dist/ask.d.ts
CHANGED
package/dist/ask.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ask = void 0;
|
|
6
|
+
exports.checkItem = exports.ask = void 0;
|
|
7
7
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
8
|
inquirer_1.default.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));
|
|
9
9
|
const specSymbols = {
|
|
@@ -18,10 +18,16 @@ const ask = async (message, choices) => {
|
|
|
18
18
|
name: 'branch',
|
|
19
19
|
message,
|
|
20
20
|
source(answersSoFar, input = '') {
|
|
21
|
-
const list = choices.filter(
|
|
21
|
+
const list = choices.filter(choiceItem => checkItem(choiceItem, input));
|
|
22
22
|
return Promise.resolve(list);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
return prompt;
|
|
26
26
|
};
|
|
27
27
|
exports.ask = ask;
|
|
28
|
+
//
|
|
29
|
+
function checkItem(item, filterString) {
|
|
30
|
+
const reg = new RegExp(filterString.split('').map(s => s.trim()).filter(Boolean).join('.*').replace('.*.*', '.*'), 'gi');
|
|
31
|
+
return reg.test(item);
|
|
32
|
+
}
|
|
33
|
+
exports.checkItem = checkItem;
|
package/package.json
CHANGED
package/src/ask.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const ask = async (message: string, choices: string[]) => {
|
|
|
18
18
|
name: 'branch',
|
|
19
19
|
message,
|
|
20
20
|
source(answersSoFar, input = '') {
|
|
21
|
-
const list = choices.filter(
|
|
21
|
+
const list = choices.filter(choiceItem => checkItem(choiceItem, input));
|
|
22
22
|
|
|
23
23
|
return Promise.resolve(list);
|
|
24
24
|
}
|
|
@@ -26,3 +26,14 @@ export const ask = async (message: string, choices: string[]) => {
|
|
|
26
26
|
|
|
27
27
|
return prompt;
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
|
|
32
|
+
export function checkItem(item: string, filterString: string): boolean {
|
|
33
|
+
const reg = new RegExp(
|
|
34
|
+
filterString.split('').map(s => s.trim()).filter(Boolean).join('.*').replace('.*.*', '.*'),
|
|
35
|
+
'gi',
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return reg.test(item);
|
|
39
|
+
}
|