import readline from 'readline';

export const prompting = (message: string) => {
  return new Promise<string | null>((resolve) => {
    if (typeof prompt !== 'undefined') {
      return resolve(prompt(message));
    }

    const rl = readline.createInterface({
      input: process.stdin,
      output: process.stdout,
    });
    rl.question(`${message}: `, (id) => {
      rl.close();

      resolve(id);
    });
  });
};
