fix
This commit is contained in:
parent
d629da908e
commit
9aebbf824d
@ -4,7 +4,7 @@
|
|||||||
/* eslint-disable no-process-env */
|
/* eslint-disable no-process-env */
|
||||||
import { Persistent } from '@scode/modelling';
|
import { Persistent } from '@scode/modelling';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import yargs from 'yargs';
|
import yargs, { Options } from 'yargs';
|
||||||
import { Confirm, Input } from 'enquirer';
|
import { Confirm, Input } from 'enquirer';
|
||||||
|
|
||||||
enum OptionType {
|
enum OptionType {
|
||||||
@ -68,7 +68,7 @@ export class InteractiveOptions extends Persistent {
|
|||||||
].includes (typeof value))
|
].includes (typeof value))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const as_num = parseInt (value);
|
const as_num = parseInt (String (value));
|
||||||
const is_num = !isNaN (as_num);
|
const is_num = !isNaN (as_num);
|
||||||
if (is_num) {
|
if (is_num) {
|
||||||
opt.value = as_num;
|
opt.value = as_num;
|
||||||
@ -87,7 +87,8 @@ export class InteractiveOptions extends Persistent {
|
|||||||
const is_bool = [
|
const is_bool = [
|
||||||
0,
|
0,
|
||||||
1
|
1
|
||||||
].includes (value) || (/^(?:true|false)$/ui).test (value);
|
].includes (parseInt (String (value)))
|
||||||
|
|| (/^(?:true|false)$/ui).test (value as string);
|
||||||
if (is_bool) {
|
if (is_bool) {
|
||||||
const as_bool = value === 1 || (/true/ui).test (value as string);
|
const as_bool = value === 1 || (/true/ui).test (value as string);
|
||||||
opt.value = as_bool;
|
opt.value = as_bool;
|
||||||
@ -127,7 +128,7 @@ export class InteractiveOptions extends Persistent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async get_args_options (): Promise<void> {
|
private async get_args_options (): Promise<void> {
|
||||||
const yargs_config = {
|
const yargs_config: Record<string, Options> = {
|
||||||
quiet: {
|
quiet: {
|
||||||
alias: 'q',
|
alias: 'q',
|
||||||
default: false,
|
default: false,
|
||||||
@ -143,7 +144,8 @@ export class InteractiveOptions extends Persistent {
|
|||||||
describe: opt.description
|
describe: opt.description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const argv = yargs.options (yargs_config);
|
const argv = yargs.options (yargs_config)
|
||||||
|
.parse ();
|
||||||
await Promise.all (this.options.map ((opt) => {
|
await Promise.all (this.options.map ((opt) => {
|
||||||
if (typeof argv[opt.name] !== 'undefined')
|
if (typeof argv[opt.name] !== 'undefined')
|
||||||
return this.assign_arg (opt, argv[opt.name]);
|
return this.assign_arg (opt, argv[opt.name]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user