infinitered / gluegun

A delightful toolkit for building TypeScript-powered command-line apps.
MIT License
2.96k stars 147 forks source link

toolbox.prompt overwrites all items #753

Closed imranMnts closed 2 years ago

imranMnts commented 2 years ago

Describe the bug toolbox.prompt.ask overwrites all items

To Reproduce

Issue :

let addNewItem = true;
const result = [];
while (addNewItem) {
  const item = await toolbox.prompt.ask({
      type: 'input',
      name: `name`,
      message: `message`,
  });

  result.push(item);
  addNewItem = await toolbox.prompt.confirm('continue?');
}
console.log('result: ', result);

the first time, we put 1 as name input, and 2 the second time

Result

print: result: [ { name: '2', yesno: false }, { name: '2', yesno: false } ]

Expected behavior print: result: [ { name: '1' }, { name: '2' } ]

Doctor (please complete the following information):

jamonholmgren commented 2 years ago

@imranMnts Thanks for the bug report. Would you mind taking a shot at a PR?

jamonholmgren commented 2 years ago

This would be a good opportunity for a regression test as well.

imranMnts commented 2 years ago

@jamonholmgren I created this PR https://github.com/infinitered/gluegun/pull/754

can you please have a look?

imranMnts commented 2 years ago

@jamonholmgren

Can we have an update, please?

infinitered-circleci commented 2 years ago

:tada: This issue has been resolved in version 5.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: