How to use the prompt.getAsync function in prompt

To help you get started, we’ve selected a few prompt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github suguru03 / leetcode / gulp / tasks / init.ts View on Github external
export async function init() {
  prompt.start();
  const { num } = await prompt.getAsync(schema);

  const { data } = await axios(`${base}/api/problems/all/`);
  const item = _.find(data.stat_status_pairs, item => item.stat.frontend_question_id === num);
  if (!item) {
    throw new Error(`${num} is not found`);
  }
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  await setLanguage(page);

  // load the problem page, it may need to adjust the timeout
  await createProblem(page, item.stat);
  await browser.close();
}
github alefi87 / programmers-idea-book / numbers / change-return / index.js View on Github external
},
];

for (let i = 0; i < items.length; i++) {
  console.log(`${i + 1}. ${items[i]}${(' '.repeat(width - items[i].length))}${prices[items[i]]}`);
}

const onError = function onError(err) {
  console.log(err.message);
  process.exit();
};

let price = -1;
Promise.promisifyAll(prompt);
prompt.start();
prompt.getAsync(itemProps).then((response) => {
  if (response.item > items.length || response.item < 1) {
    onError(new Error('Chosen item does not exist.'));
  }
  price = prices[items[response.item - 1]];
  return prompt.getAsync(amountProps);
}).then((response) => {
  const change = calculateChange(price, parseFloat(response.amount));
  console.log(`Your change: ${JSON.stringify(change)}`);
});
github bookercodes / communitycasts.co / admin.js View on Github external
current = current.then(function() {
      console.log('Title: "' + screencast.title + '".');
      return prompt.getAsync(property);
    }).then(function(result) {
      if (result.approve === 'yes') {
github alefi87 / programmers-idea-book / numbers / change-return / index.js View on Github external
prompt.getAsync(itemProps).then((response) => {
  if (response.item > items.length || response.item < 1) {
    onError(new Error('Chosen item does not exist.'));
  }
  price = prices[items[response.item - 1]];
  return prompt.getAsync(amountProps);
}).then((response) => {
  const change = calculateChange(price, parseFloat(response.amount));