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

7
gog.js
View file

@ -1,13 +1,8 @@
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
import path from 'path';
import { dirs, jsonDb, datetime, filenamify, notify, html_game_list } from './util.js';
import { dirs, jsonDb, datetime, 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://www.gog.com/en';
console.log(datetime(), 'started checking gog');