Comparing version 2.0.0 to 2.0.1
@@ -34,3 +34,3 @@ import chalk from "chalk"; | ||
type: inputType, | ||
name: option.long.replace("--", ""), | ||
name: camelize(option.long.replace("--", "")), | ||
message: option.description, | ||
@@ -41,14 +41,9 @@ choices: hasChoices ? convertStringToOptions(option.flags) : undefined, | ||
export async function autoprompt(program, autoPromptOpts) { | ||
const options = program.options.map(validateOption); | ||
program.parseOptions(process.argv); | ||
const parsedOptions = program.opts(); | ||
const promptedOptions = await promptForMissingOptions(autoPromptOpts?.prompter ?? prompt, options, parsedOptions); | ||
const args = process.argv; | ||
args.push(...Object.entries(promptedOptions) | ||
.filter(([_key, value]) => value != null) | ||
.map(([key, value]) => { | ||
return `--${key}=${value}`; | ||
})); | ||
program.parse(args); | ||
return program; | ||
program.hook("preAction", async (_rootCommand, subCommand) => { | ||
const options = subCommand.options.map(validateOption); | ||
// subCommand.parseOptions(); | ||
const promptedOptions = await promptForMissingOptions(autoPromptOpts?.prompter ?? prompt, options, subCommand.opts()); | ||
Object.assign(subCommand.opts(), promptedOptions); | ||
}); | ||
return program.parseAsync(); | ||
} | ||
@@ -58,2 +53,5 @@ export async function promptForMissingOptions(prompter, options, parsedOptions) { | ||
.filter((opt) => { | ||
if (opt.flags.includes("(optional)")) { | ||
return false; | ||
} | ||
// only prompt for options that were not passed in | ||
@@ -60,0 +58,0 @@ const missingValue = !parsedOptions[camelize(opt.long.replace("--", ""))]; |
{ | ||
"name": "autoprompt", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13383
101