Skip to content

The method passed into question is executed automatically #424

Description

@hcl-z

Is your feature request related to a problem?

I'd like to pass a callback-like method in question and get it and execute it when Onsubmit, but the current code will pre-execute all the methods that aren't in special functions`

  for (question of questions) {
    ({ name, type } = question);

    // evaluate type first and skip if type is a falsy value
    if (typeof type === 'function') {
      type = await type(answer, { ...answers }, question)
      question['type'] = type
    }
    if (!type) continue;

    // if property is a function, invoke it unless it's a special function
    for (let key in question) {
      if (passOn.includes(key)) continue;
      let value = question[key];
      question[key] = typeof value === 'function' ? await value(answer, { ...answers }, lastPrompt) : value;
    }

Describe the solution you'd like

Don't handle the method passed in in question, leave it intact in onSubmit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions