penguins-eggs
Version:
A remaster system tool, compatible with Arch, Debian, Devuan, Ubuntu and others
31 lines (30 loc) • 672 B
JavaScript
import Utils from '../../../classes/utils.js';
import { render } from 'ink';
/**
* confirm
* @returns
*/
export async function confirm(elem, msg = "Confirm") {
redraw(elem);
const result = JSON.parse(await Utils.customConfirmAbort(msg));
let retval = false;
if (result.confirm === 'Yes') {
retval = true;
}
else if (result.confirm === 'Abort') {
process.exit();
}
return retval;
}
/**
* Occorre farglierlo rigenerare a forza
* anche quando NON cambiano i dati
* forceUpdate
*/
function redraw(elem) {
let opt = {};
opt.patchConsole = true;
opt.debug = false;
console.clear();
render(elem, opt);
}