@inquirer/password 1.1.5 → 1.1.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/dist/cjs/index.js CHANGED
@@ -5,16 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const input_1 = __importDefault(require("@inquirer/input"));
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
+ const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
8
9
  const password = (config, context) => {
9
- if (config.transformer) {
10
+ if ('transformer' in config) {
10
11
  throw new Error('Inquirer password prompt do not support custom transformer function. Use the input prompt instead.');
11
12
  }
12
13
  return (0, input_1.default)(Object.assign(Object.assign({}, config), { default: undefined, transformer(input, { isFinal }) {
13
14
  if (config.mask) {
14
- return String(config.mask).repeat(input.length);
15
+ const maskChar = typeof config.mask === 'string' ? config.mask : '*';
16
+ return maskChar.repeat(input.length);
15
17
  }
16
18
  if (!isFinal) {
17
- return chalk_1.default.dim('[input is masked]');
19
+ return `${chalk_1.default.dim('[input is masked]')}${ansi_escapes_1.default.cursorHide}`;
18
20
  }
19
21
  return '';
20
22
  } }), context);
@@ -1,6 +1,7 @@
1
1
  import type { Prompt } from '@inquirer/type';
2
2
  import input from '@inquirer/input';
3
- type PasswordConfig = Parameters<typeof input>[0] & {
3
+ type InputConfig = Parameters<typeof input>[0];
4
+ type PasswordConfig = Omit<InputConfig, 'transformer' | 'default'> & {
4
5
  mask?: boolean | string;
5
6
  };
6
7
  declare const password: Prompt<string, PasswordConfig>;
@@ -1,7 +1,8 @@
1
1
  import input from '@inquirer/input';
2
2
  import chalk from 'chalk';
3
+ import ansiEscapes from 'ansi-escapes';
3
4
  const password = (config, context) => {
4
- if (config.transformer) {
5
+ if ('transformer' in config) {
5
6
  throw new Error('Inquirer password prompt do not support custom transformer function. Use the input prompt instead.');
6
7
  }
7
8
  return input({
@@ -9,10 +10,11 @@ const password = (config, context) => {
9
10
  default: undefined,
10
11
  transformer(input, { isFinal }) {
11
12
  if (config.mask) {
12
- return String(config.mask).repeat(input.length);
13
+ const maskChar = typeof config.mask === 'string' ? config.mask : '*';
14
+ return maskChar.repeat(input.length);
13
15
  }
14
16
  if (!isFinal) {
15
- return chalk.dim('[input is masked]');
17
+ return `${chalk.dim('[input is masked]')}${ansiEscapes.cursorHide}`;
16
18
  }
17
19
  return '';
18
20
  },
@@ -1,6 +1,7 @@
1
1
  import type { Prompt } from '@inquirer/type';
2
2
  import input from '@inquirer/input';
3
- type PasswordConfig = Parameters<typeof input>[0] & {
3
+ type InputConfig = Parameters<typeof input>[0];
4
+ type PasswordConfig = Omit<InputConfig, 'transformer' | 'default'> & {
4
5
  mask?: boolean | string;
5
6
  };
6
7
  declare const password: Prompt<string, PasswordConfig>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/password",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "engines": {
5
5
  "node": ">=14.18.0"
6
6
  },
@@ -57,10 +57,14 @@
57
57
  "license": "MIT",
58
58
  "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/password/README.md",
59
59
  "dependencies": {
60
- "@inquirer/input": "^1.2.5",
60
+ "@inquirer/input": "^1.2.7",
61
61
  "@inquirer/type": "^1.1.1",
62
+ "ansi-escapes": "^4.3.2",
62
63
  "chalk": "^4.1.2"
63
64
  },
65
+ "devDependencies": {
66
+ "@inquirer/testing": "^2.1.2"
67
+ },
64
68
  "scripts": {
65
69
  "tsc": "yarn run clean && yarn run tsc:esm && yarn run tsc:cjs",
66
70
  "clean": "rm -rf dist",
@@ -83,5 +87,5 @@
83
87
  }
84
88
  }
85
89
  },
86
- "gitHead": "18144628b03b62c346cb7d9d55a2c526b1ed5d8a"
90
+ "gitHead": "dd31d57ed3b1d0771e24cc34bc72e5bedb63a1d7"
87
91
  }