inquirerer 1.6.0 → 1.7.0

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/esm/prompt.js CHANGED
@@ -100,13 +100,7 @@ export class Inquirerer {
100
100
  if (!noTty) {
101
101
  this.rl = readline.createInterface({
102
102
  input,
103
- // dissallow readline from prompting user, since we'll handle it!
104
103
  output
105
- // : new Writable({
106
- // write(chunk, encoding, callback) {
107
- // callback(); // Do nothing with the data
108
- // }
109
- // })
110
104
  });
111
105
  this.keypress = new TerminalKeypress(noTty, input);
112
106
  }
@@ -252,9 +246,10 @@ export class Inquirerer {
252
246
  this.close();
253
247
  }
254
248
  async prompt(argv, questions, options) {
255
- let obj = (this.mutateArgs || options.mutateArgs) ? argv : { ...argv };
249
+ // use local mutateArgs if defined, otherwise global mutateArgs
250
+ const shouldMutate = options?.mutateArgs !== undefined ? options.mutateArgs : this.mutateArgs;
251
+ let obj = shouldMutate ? argv : { ...argv };
256
252
  // Assuming questions is an array of Question objects and argv is the parsed command line arguments object.
257
- // @ts-ignore
258
253
  if (this.noTty && questions.some(question => question.required && this.isEmptyAnswer(argv[question.name]))) {
259
254
  for (let index = 0; index < questions.length; index++) {
260
255
  const question = questions[index];
@@ -263,7 +258,6 @@ export class Inquirerer {
263
258
  obj[question.name] = question.default;
264
259
  }
265
260
  }
266
- // @ts-ignore
267
261
  if (!questions.some(question => question.required && this.isEmptyAnswer(argv[question.name]))) {
268
262
  return obj;
269
263
  }
@@ -283,6 +277,11 @@ export class Inquirerer {
283
277
  for (let index = 0; index < questions.length; index++) {
284
278
  const question = questions[index];
285
279
  const ctx = new PromptContext();
280
+ // obj is already either argv itself, or a clone, but let's check if it has the property
281
+ if (question.name in obj) {
282
+ ctx.nextQuestion();
283
+ continue;
284
+ }
286
285
  // Apply default value if applicable
287
286
  if ('default' in question && (this.useDefaults || question.useDefault)) {
288
287
  obj[question.name] = question.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inquirerer",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
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": "7c0bfaacaac54980e2a1a1c918fd069e9260437f"
38
+ "gitHead": "273e730c2481312b2d332d3711b1728210799e83"
39
39
  }
package/prompt.js CHANGED
@@ -106,13 +106,7 @@ class Inquirerer {
106
106
  if (!noTty) {
107
107
  this.rl = readline_1.default.createInterface({
108
108
  input,
109
- // dissallow readline from prompting user, since we'll handle it!
110
109
  output
111
- // : new Writable({
112
- // write(chunk, encoding, callback) {
113
- // callback(); // Do nothing with the data
114
- // }
115
- // })
116
110
  });
117
111
  this.keypress = new keypress_1.TerminalKeypress(noTty, input);
118
112
  }
@@ -258,9 +252,10 @@ class Inquirerer {
258
252
  this.close();
259
253
  }
260
254
  async prompt(argv, questions, options) {
261
- let obj = (this.mutateArgs || options.mutateArgs) ? argv : { ...argv };
255
+ // use local mutateArgs if defined, otherwise global mutateArgs
256
+ const shouldMutate = options?.mutateArgs !== undefined ? options.mutateArgs : this.mutateArgs;
257
+ let obj = shouldMutate ? argv : { ...argv };
262
258
  // Assuming questions is an array of Question objects and argv is the parsed command line arguments object.
263
- // @ts-ignore
264
259
  if (this.noTty && questions.some(question => question.required && this.isEmptyAnswer(argv[question.name]))) {
265
260
  for (let index = 0; index < questions.length; index++) {
266
261
  const question = questions[index];
@@ -269,7 +264,6 @@ class Inquirerer {
269
264
  obj[question.name] = question.default;
270
265
  }
271
266
  }
272
- // @ts-ignore
273
267
  if (!questions.some(question => question.required && this.isEmptyAnswer(argv[question.name]))) {
274
268
  return obj;
275
269
  }
@@ -289,6 +283,11 @@ class Inquirerer {
289
283
  for (let index = 0; index < questions.length; index++) {
290
284
  const question = questions[index];
291
285
  const ctx = new PromptContext();
286
+ // obj is already either argv itself, or a clone, but let's check if it has the property
287
+ if (question.name in obj) {
288
+ ctx.nextQuestion();
289
+ continue;
290
+ }
292
291
  // Apply default value if applicable
293
292
  if ('default' in question && (this.useDefaults || question.useDefault)) {
294
293
  obj[question.name] = question.default;