avoid non-standard input types

This commit is contained in:
Alex Bosworth 2026-06-16 10:25:42 -07:00
parent 9fad1fab89
commit c06ff5a953
No known key found for this signature in database
GPG key ID: E80D2F3F311FD87E
5 changed files with 35 additions and 5 deletions

View file

@ -1,6 +1,6 @@
# Versions
## 22.1.2
## 22.1.3
- Improve support for SOCKS proxy on old node versions

View file

@ -10,6 +10,7 @@ const {getNodeAlias} = require('ln-sync');
const {returnResult} = require('asyncjs-util');
const {calls} = require('./api');
const promptType = require('./prompt_type');
const {assign} = Object;
const fromLnSync = 'ln-sync';
@ -126,7 +127,7 @@ module.exports = ({ask, lnd, logger, method, params}, cbk) => {
name: named,
prefix: `[${named}]`,
suffix: !!argument.optional ? ' (Optional)' : String(),
type: argument.type || 'input',
type: promptType({type: argument.type}).type || 'input',
validate: async input => {
const isNumber = argument.type === 'number';

29
commands/prompt_type.js Normal file
View file

@ -0,0 +1,29 @@
/** Derive a prompt type from an argument type
{
type: <Prompt Type String>
}
@returns
{
[type]: <Sanitized Prompt Type String>
}
*/
module.exports = ({type}) => {
switch (type) {
case 'checkbox':
case 'confirm':
case 'editor':
case 'expand':
case 'input':
case 'number':
case 'password':
case 'rawlist':
case 'search':
case 'select':
return {type};
default:
return {};
}
};

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "balanceofsatoshis",
"version": "22.1.2",
"version": "22.1.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "balanceofsatoshis",
"version": "22.1.2",
"version": "22.1.3",
"license": "MIT",
"dependencies": {
"@alexbosworth/blockchain": "3.2.0",

View file

@ -81,5 +81,5 @@
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64 -t alexbosworth/balanceofsatoshis -t alexbosworth/balanceofsatoshis:$npm_package_version --push .",
"test": "npx nyc@17.1.0 node --experimental-test-coverage --test test/arrays/*.js test/balances/*.js test/chain/*.js test/display/*.js test/encryption/*.js test/lnd/*.js test/network/*.js test/nodes/*.js test/peers/*.js test/responses/*.js test/routing/*.js test/services/*.js test/swaps/*.js test/tags/*.js test/telegram/*.js test/wallets/*.js"
},
"version": "22.1.2"
"version": "22.1.3"
}