inquirerer 2.0.5 → 2.0.7

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/README.md CHANGED
@@ -6,12 +6,12 @@
6
6
 
7
7
  <p align="center" width="100%">
8
8
 
9
- <a href="https://github.com/pyramation/inquirerer2/actions/workflows/run-tests.yml">
10
- <img height="20" src="https://github.com/pyramation/inquirerer2/actions/workflows/run-tests.yml/badge.svg" />
9
+ <a href="https://github.com/pyramation/inquirerer/actions/workflows/run-tests.yml">
10
+ <img height="20" src="https://github.com/pyramation/inquirerer/actions/workflows/run-tests.yml/badge.svg" />
11
11
  </a>
12
- <a href="https://github.com/pyramation/inquirerer2/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
12
+ <a href="https://github.com/pyramation/inquirerer/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
13
13
  <a href="https://www.npmjs.com/package/inquirerer"><img height="20" src="https://img.shields.io/npm/dt/inquirerer"></a>
14
- <a href="https://www.npmjs.com/package/inquirerer"><img height="20" src="https://img.shields.io/github/package-json/v/pyramation/inquirerer2?filename=packages%2Finquirerer%2Fpackage.json"></a>
14
+ <a href="https://www.npmjs.com/package/inquirerer"><img height="20" src="https://img.shields.io/github/package-json/v/pyramation/inquirerer?filename=packages%2Finquirerer%2Fpackage.json"></a>
15
15
  </p>
16
16
 
17
17
  This library is designed to facilitate the creation of command-line utilities by providing a robust framework for capturing user input through interactive prompts. It supports a variety of question types, making it highly flexible and suitable for a wide range of applications.
package/esm/prompt.js CHANGED
@@ -445,13 +445,16 @@ export class Inquirerer {
445
445
  : result.filter(opt => opt.selected);
446
446
  }
447
447
  handleOverridesWithOptions(argv, obj, question) {
448
- if (typeof argv[question.name] === 'string') {
449
- const options = this.sanitizeOptions(question);
450
- const input = argv[question.name];
451
- const found = options.find(opt => opt.name === input || String(opt.value) === input);
452
- if (typeof found !== 'undefined') {
453
- obj[question.name] = found.value;
454
- }
448
+ const input = argv[question.name];
449
+ if (typeof input !== 'string')
450
+ return;
451
+ const options = this.sanitizeOptions(question);
452
+ const found = options.find(opt => opt.name === input || String(opt.value) === input);
453
+ if (found) {
454
+ obj[question.name] = found.value;
455
+ }
456
+ else if (question.allowCustomOptions) {
457
+ obj[question.name] = input; // Store as-is
455
458
  }
456
459
  }
457
460
  async handleQuestionType(question, ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inquirerer",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "inquirerer",
6
6
  "main": "index.js",
@@ -35,5 +35,5 @@
35
35
  "minimist": "^1.2.8"
36
36
  },
37
37
  "keywords": [],
38
- "gitHead": "5302e9c3747a4b0ad21058538b96e848104cc41d"
38
+ "gitHead": "7287f9c5f9ad00ff16c8a5ce562c50a181df5074"
39
39
  }
package/prompt.js CHANGED
@@ -451,13 +451,16 @@ class Inquirerer {
451
451
  : result.filter(opt => opt.selected);
452
452
  }
453
453
  handleOverridesWithOptions(argv, obj, question) {
454
- if (typeof argv[question.name] === 'string') {
455
- const options = this.sanitizeOptions(question);
456
- const input = argv[question.name];
457
- const found = options.find(opt => opt.name === input || String(opt.value) === input);
458
- if (typeof found !== 'undefined') {
459
- obj[question.name] = found.value;
460
- }
454
+ const input = argv[question.name];
455
+ if (typeof input !== 'string')
456
+ return;
457
+ const options = this.sanitizeOptions(question);
458
+ const found = options.find(opt => opt.name === input || String(opt.value) === input);
459
+ if (found) {
460
+ obj[question.name] = found.value;
461
+ }
462
+ else if (question.allowCustomOptions) {
463
+ obj[question.name] = input; // Store as-is
461
464
  }
462
465
  }
463
466
  async handleQuestionType(question, ctx) {
@@ -32,11 +32,13 @@ export interface AutocompleteQuestion extends BaseQuestion {
32
32
  type: 'autocomplete';
33
33
  options: (string | OptionValue)[];
34
34
  maxDisplayLines?: number;
35
+ allowCustomOptions?: boolean;
35
36
  }
36
37
  export interface ListQuestion extends BaseQuestion {
37
38
  type: 'list';
38
39
  options: (string | OptionValue)[];
39
40
  maxDisplayLines?: number;
41
+ allowCustomOptions?: boolean;
40
42
  }
41
43
  export interface CheckboxQuestion extends BaseQuestion {
42
44
  type: 'checkbox';