Socket
Socket
Sign inDemoInstall

inquirer

Package Overview
Dependencies
62
Maintainers
4
Versions
151
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.2.19 to 9.2.20

8

lib/objects/choice.js

@@ -13,3 +13,2 @@ /**

if (val instanceof Choice || val.type === 'separator') {
// eslint-disable-next-line no-constructor-return
return val;

@@ -30,8 +29,5 @@ }

if (typeof val.disabled === 'function') {
this.disabled = val.disabled(answers);
} else {
this.disabled = val.disabled;
}
this.disabled =
typeof val.disabled === 'function' ? val.disabled(answers) : val.disabled;
}
}

@@ -50,2 +50,11 @@ import assert from 'node:assert';

[Symbol.iterator]() {
const data = this.choices;
let index = -1;
return {
next: () => ({ value: data[++index], done: !(index in data) }),
};
}
/**

@@ -110,2 +119,6 @@ * Get a valid choice from the collection

some(func) {
return this.choices.some(func);
}
push(...args) {

@@ -112,0 +125,0 @@ const objs = args.map((val) => new Choice(val));

@@ -14,3 +14,3 @@ import chalk from 'chalk';

this.type = 'separator';
this.line = chalk.dim(line || new Array(15).join(figures.line));
this.line = chalk.dim(line || Array.from({ length: 15 }).join(figures.line));
}

@@ -17,0 +17,0 @@

@@ -97,3 +97,2 @@ import defaults from 'lodash/defaults.js';

handleSubmitEvents(submit) {
const self = this;
const validate = runAsync(this.opt.validate);

@@ -104,11 +103,11 @@ const asyncFilter = runAsync(this.opt.filter);

this.startSpinner(value, this.opt.filteringText);
return asyncFilter(value, self.answers).then(
return asyncFilter(value, this.answers).then(
(filteredValue) => {
this.startSpinner(filteredValue, this.opt.validatingText);
return validate(filteredValue, self.answers).then(
return validate(filteredValue, this.answers).then(
(isValid) => ({ isValid, value: filteredValue }),
(err) => ({ isValid: err, value: filteredValue }),
(error_) => ({ isValid: error_, value: filteredValue }),
);
},
(err) => ({ isValid: err }),
(error_) => ({ isValid: error_ }),
);

@@ -172,7 +171,6 @@ }),

// If default password is supplied, hide it
if (this.opt.type === 'password') {
message += chalk.italic.dim('[hidden] ');
} else {
message += chalk.dim('(' + this.opt.default + ') ');
}
message +=
this.opt.type === 'password'
? chalk.italic.dim('[hidden] ')
: chalk.dim('(' + this.opt.default + ') ');
}

@@ -179,0 +177,0 @@

@@ -23,7 +23,7 @@ /**

if (Array.isArray(this.opt.default)) {
this.opt.choices.forEach(function (choice) {
if (this.opt.default.indexOf(choice.value) >= 0) {
for (const choice of this.opt.choices) {
if (this.opt.default.includes(choice.value)) {
choice.checked = true;
}
}, this);
}
}

@@ -196,4 +196,4 @@

onAllKey() {
const shouldBeChecked = Boolean(
this.opt.choices.find((choice) => choice.type !== 'separator' && !choice.checked),
const shouldBeChecked = this.opt.choices.some(
(choice) => choice.type !== 'separator' && !choice.checked,
);

@@ -253,7 +253,4 @@

const line = getCheckbox(choice.checked) + ' ' + choice.name;
if (i - separatorOffset === pointer) {
output += chalk.cyan(figures.pointer + line);
} else {
output += ' ' + line;
}
output +=
i - separatorOffset === pointer ? chalk.cyan(figures.pointer + line) : ' ' + line;
}

@@ -264,3 +261,3 @@

return output.replace(/\n$/, '');
return output.replaceAll(/\n$/g, '');
}

@@ -267,0 +264,0 @@

@@ -57,7 +57,6 @@ /**

if (this.status === 'answered') {
message += chalk.dim('Received');
} else {
message += chalk.dim('Press <enter> to launch your preferred editor.');
}
message +=
this.status === 'answered'
? chalk.dim('Received')
: chalk.dim('Press <enter> to launch your preferred editor.');

@@ -64,0 +63,0 @@ if (error) {

@@ -212,3 +212,3 @@ /**

if (errors.length) {
if (errors.length > 0) {
throw new Error(

@@ -215,0 +215,0 @@ 'Duplicate key error: `key` param must be unique. Duplicates: ' +

@@ -50,7 +50,3 @@ /**

if (isFinal) {
appendContent = this.answer;
} else {
appendContent = this.rl.line;
}
appendContent = isFinal ? this.answer : this.rl.line;

@@ -57,0 +53,0 @@ if (transformer) {

@@ -52,4 +52,2 @@ /**

const self = this;
const events = observe(this.rl);

@@ -66,3 +64,3 @@ events.normalizedUpKey.pipe(takeUntil(events.line)).forEach(this.onUpKey.bind(this));

flatMap((value) =>
runAsync(self.opt.filter)(value, self.answers).catch((err) => err),
runAsync(this.opt.filter)(value, this.answers).catch((error) => error),
),

@@ -206,3 +204,3 @@ )

return output.replace(/\n$/, '');
return output.replaceAll(/\n$/g, '');
}

@@ -24,4 +24,4 @@ /**

// If the input was invalid return the default value.
return this.opt.default == null ? NaN : this.opt.default;
return this.opt.default == null ? Number.NaN : this.opt.default;
}
}

@@ -17,3 +17,3 @@ /**

return new Array(input.length + 1).join(maskChar);
return Array.from({ length: input.length + 1 }).join(maskChar);
}

@@ -59,7 +59,6 @@

if (this.status === 'answered') {
message += this.getMaskedValue(this.answer);
} else {
message += this.getMaskedValue(this.rl.line || '');
}
message +=
this.status === 'answered'
? this.getMaskedValue(this.answer)
: this.getMaskedValue(this.rl.line || '');

@@ -66,0 +65,0 @@ if (error) {

@@ -153,13 +153,9 @@ /**

if (this.lastKey === 'arrow') {
index = this.hiddenLine.length ? Number(this.hiddenLine) - 1 : 0;
index = this.hiddenLine.length > 0 ? Number(this.hiddenLine) - 1 : 0;
} else {
index = this.rl.line.length ? Number(this.rl.line) - 1 : 0;
index = this.rl.line.length > 0 ? Number(this.rl.line) - 1 : 0;
}
this.lastKey = '';
if (this.opt.choices.getChoice(index)) {
this.selected = index;
} else {
this.selected = undefined;
}
this.selected = this.opt.choices.getChoice(index) ? index : undefined;
this.render();

@@ -166,0 +162,0 @@ }

@@ -71,3 +71,3 @@ /**

enforceLF(str) {
return str.match(/[\r\n]$/) ? str : str + '\n';
return /[\n\r]$/.test(str) ? str : str + '\n';
}

@@ -84,3 +84,3 @@

// Write message to screen and setPrompt to control backspace
this.rl.setPrompt(msgLines[msgLines.length - 1]);
this.rl.setPrompt(msgLines.at(-1));

@@ -87,0 +87,0 @@ if (this.rl.output.rows === 0 && this.rl.output.columns === 0) {

@@ -26,7 +26,3 @@ import isPlainObject from 'lodash/isPlainObject.js';

// Keep global reference to the answers
if (_.isPlainObject(answers)) {
this.answers = { ...answers };
} else {
this.answers = {};
}
this.answers = _.isPlainObject(answers) ? { ...answers } : {};

@@ -33,0 +29,0 @@ // Make sure questions is an array.

@@ -7,3 +7,3 @@ import { fromEvent, filter, map, share, takeUntil } from 'rxjs';

export default function (rl) {
export default function observe(rl) {
const keypress = fromEvent(rl.input, 'keypress', normalizeKeypressEvents)

@@ -35,3 +35,3 @@ .pipe(takeUntil(fromEvent(rl, 'close')))

numberKey: keypress.pipe(
filter((e) => e.value && '123456789'.indexOf(e.value) >= 0),
filter((e) => e.value && '123456789'.includes(e.value)),
map((e) => Number(e.value)),

@@ -38,0 +38,0 @@ share(),

@@ -70,3 +70,3 @@ import cliWidth from 'cli-width';

let prompt = rawPromptLine;
if (this.rl.line.length) {
if (this.rl.line.length > 0) {
prompt = prompt.slice(0, -this.rl.line.length);

@@ -73,0 +73,0 @@ }

{
"name": "inquirer",
"type": "module",
"version": "9.2.19",
"version": "9.2.20",
"description": "A collection of common interactive command line user interfaces.",

@@ -79,3 +79,3 @@ "author": "Simon Boudrias <admin@simonboudrias.com>",

"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/inquirer/README.md",
"gitHead": "e986c9afc26321c3448f87f55795f7d9b8a9d452"
"gitHead": "d0e92901ebb7eb77d027786a2e1ac41fc15326b6"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc