Skip to content

Commit

Permalink
fix: Remove dependency of lodash isString (#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmywarting committed Nov 17, 2021
1 parent e5bb189 commit 4769839
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions packages/inquirer/lib/objects/choice.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';
const _ = {
isString: require('lodash/isString'),
isNumber: require('lodash/isNumber'),
extend: require('lodash/extend'),
isFunction: require('lodash/isFunction'),
Expand All @@ -22,7 +21,7 @@ module.exports = class Choice {
return val;
}

if (_.isString(val) || _.isNumber(val)) {
if (typeof val === 'string' || _.isNumber(val)) {
this.name = String(val);
this.value = val;
this.short = String(val);
Expand Down
5 changes: 3 additions & 2 deletions packages/inquirer/lib/prompts/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

const _ = {
map: require('lodash/map'),
isString: require('lodash/isString'),
};
const chalk = require('chalk');
const cliCursor = require('cli-cursor');
Expand Down Expand Up @@ -248,7 +247,9 @@ function renderChoices(choices, pointer) {
if (choice.disabled) {
separatorOffset++;
output += ' - ' + choice.name;
output += ' (' + (_.isString(choice.disabled) ? choice.disabled : 'Disabled') + ')';
output += ` (${
typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'
})`;
} else {
const line = getCheckbox(choice.checked) + ' ' + choice.name;
if (i - separatorOffset === pointer) {
Expand Down
3 changes: 1 addition & 2 deletions packages/inquirer/lib/prompts/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

const _ = {
uniq: require('lodash/uniq'),
isString: require('lodash/isString'),
isNumber: require('lodash/isNumber'),
findIndex: require('lodash/findIndex'),
};
Expand Down Expand Up @@ -236,7 +235,7 @@ class ExpandPrompt extends Base {
let defIndex = choices.realLength - 1;
if (_.isNumber(defaultChoice) && this.opt.choices.getChoice(defaultChoice)) {
defIndex = defaultChoice;
} else if (_.isString(defaultChoice)) {
} else if (typeof defaultChoice === 'string') {
const index = _.findIndex(
choices.realChoices,
({ value }) => value === defaultChoice
Expand Down
5 changes: 3 additions & 2 deletions packages/inquirer/lib/prompts/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
const _ = {
isNumber: require('lodash/isNumber'),
findIndex: require('lodash/findIndex'),
isString: require('lodash/isString'),
};
const chalk = require('chalk');
const figures = require('figures');
Expand Down Expand Up @@ -194,7 +193,9 @@ function listRender(choices, pointer) {
if (choice.disabled) {
separatorOffset++;
output += ' - ' + choice.name;
output += ' (' + (_.isString(choice.disabled) ? choice.disabled : 'Disabled') + ')';
output += ` (${
typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'
})`;
output += '\n';
return;
}
Expand Down

0 comments on commit 4769839

Please sign in to comment.