extract prompt into util.js

This commit is contained in:
Ralf Vogler 2023-02-03 16:03:01 +01:00
parent 21a4e06209
commit eb17a49628
4 changed files with 15 additions and 18 deletions

View file

@ -2,14 +2,9 @@ import { firefox } from 'playwright'; // stealth plugin needs no outdated playwr
import { authenticator } from 'otplib';
import path from 'path';
import { existsSync, writeFileSync } from 'fs';
import { dirs, jsonDb, datetime, stealth, filenamify, notify, html_game_list } from './util.js';
import { dirs, jsonDb, datetime, stealth, filenamify, prompt, notify, html_game_list } from './util.js';
import { cfg } from './config.js';
import prompts from 'prompts'; // alternatives: enquirer, inquirer
// import enquirer from 'enquirer'; const { prompt } = enquirer;
// single prompt that just returns the non-empty value instead of an object - why name things if there's just one?
const prompt = async o => (await prompts({name: 'name', type: 'text', message: 'Enter value', validate: s => s.length, ...o})).name;
const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games';
const URL_LOGIN = 'https://www.epicgames.com/id/login?lang=en-US&noHostRedirect=true&redirectUrl=' + URL_CLAIM;