@inquirer/confirm 1.0.2 → 1.0.4

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
@@ -22,10 +22,11 @@ const answer = await confirm({ message: 'Enter your name' });
22
22
 
23
23
  ## Options
24
24
 
25
- | Property | Type | Required | Description |
26
- | -------- | --------- | -------- | ------------------------------ |
27
- | message | `string` | yes | The question to ask |
28
- | default | `boolean` | no | Default answer (true or false) |
25
+ | Property | Type | Required | Description |
26
+ | ----------- | --------------------- | -------- | ------------------------------------------------------- |
27
+ | message | `string` | yes | The question to ask |
28
+ | default | `boolean` | no | Default answer (true or false) |
29
+ | transformer | `(boolean) => string` | no | Transform the prompt printed message to a custom string |
29
30
 
30
31
  # License
31
32
 
@@ -12,7 +12,12 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
12
12
  (0, core_1.useKeypress)((key, rl) => {
13
13
  if ((0, core_1.isEnterKey)(key)) {
14
14
  const answer = value ? /^y(es)?/i.test(value) : config.default !== false;
15
- setValue(answer ? 'yes' : 'no');
15
+ if (typeof config.transformer === 'function') {
16
+ setValue(config.transformer(answer));
17
+ }
18
+ else {
19
+ setValue(answer ? 'yes' : 'no');
20
+ }
16
21
  setStatus('done');
17
22
  done(answer);
18
23
  }
@@ -1,5 +1,8 @@
1
- declare const _default: import("@inquirer/type").Prompt<boolean, {
1
+ import { AsyncPromptConfig } from '@inquirer/core';
2
+ type ConfirmConfig = AsyncPromptConfig & {
2
3
  message: string;
3
- default?: boolean | undefined;
4
- }>;
4
+ default?: boolean;
5
+ transformer?: (value: boolean) => string;
6
+ };
7
+ declare const _default: import("@inquirer/type").Prompt<boolean, ConfirmConfig>;
5
8
  export default _default;
@@ -7,7 +7,12 @@ export default createPrompt((config, done) => {
7
7
  useKeypress((key, rl) => {
8
8
  if (isEnterKey(key)) {
9
9
  const answer = value ? /^y(es)?/i.test(value) : config.default !== false;
10
- setValue(answer ? 'yes' : 'no');
10
+ if (typeof config.transformer === 'function') {
11
+ setValue(config.transformer(answer));
12
+ }
13
+ else {
14
+ setValue(answer ? 'yes' : 'no');
15
+ }
11
16
  setStatus('done');
12
17
  done(answer);
13
18
  }
@@ -1,5 +1,8 @@
1
- declare const _default: import("@inquirer/type").Prompt<boolean, {
1
+ import { AsyncPromptConfig } from '@inquirer/core';
2
+ type ConfirmConfig = AsyncPromptConfig & {
2
3
  message: string;
3
- default?: boolean | undefined;
4
- }>;
4
+ default?: boolean;
5
+ transformer?: (value: boolean) => string;
6
+ };
7
+ declare const _default: import("@inquirer/type").Prompt<boolean, ConfirmConfig>;
5
8
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/confirm",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Inquirer confirm prompt",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "typings": "./dist/cjs/types/index.d.mts",
@@ -54,9 +54,8 @@
54
54
  "license": "MIT",
55
55
  "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/confirm/README.md",
56
56
  "dependencies": {
57
- "@inquirer/core": "^1.0.3",
58
- "@inquirer/input": "^1.0.2",
59
- "@inquirer/type": "^1.0.2",
57
+ "@inquirer/core": "^1.1.0",
58
+ "@inquirer/type": "^1.0.3",
60
59
  "chalk": "^4.1.2"
61
60
  },
62
61
  "scripts": {
@@ -64,7 +63,7 @@
64
63
  "clean": "rm -rf dist",
65
64
  "tsc:esm": "tsc -p ./tsconfig.esm.json",
66
65
  "tsc:cjs": "tsc -p ./tsconfig.cjs.json && yarn run fix-ext",
67
- "fix-ext": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ../../tools/rename-ext.mts"
66
+ "fix-ext": "node --no-warnings=ExperimentalWarning --loader=ts-node/esm ../../tools/rename-ext.mts"
68
67
  },
69
68
  "publishConfig": {
70
69
  "access": "public"
@@ -84,5 +83,5 @@
84
83
  }
85
84
  }
86
85
  },
87
- "gitHead": "865c589ffbc4a66f328dc4e64a08646200c755f3"
86
+ "gitHead": "09f738e0ab2b52c0b33a3973f37d5256bca9a6ab"
88
87
  }