await notify before process.exit, #69
This commit is contained in:
parent
114631da4d
commit
73a7cffd47
4 changed files with 9 additions and 8 deletions
|
|
@ -84,7 +84,7 @@ try {
|
|||
}).catch(_ => { });
|
||||
} else {
|
||||
console.log('Waiting for you to login in the browser.');
|
||||
notify('epic-games: no longer signed in and not enough options set for automatic login.');
|
||||
await notify('epic-games: no longer signed in and not enough options set for automatic login.');
|
||||
if (cfg.headless) {
|
||||
console.log('Run `SHOW=1 node epic-games` to login in the opened browser.');
|
||||
await context.close(); // finishes potential recording
|
||||
|
|
|
|||
2
gog.js
2
gog.js
|
|
@ -72,7 +72,7 @@ try {
|
|||
await page.waitForSelector('#menuUsername')
|
||||
} else {
|
||||
console.log('Waiting for you to login in the browser.');
|
||||
notify('gog: no longer signed in and not enough options set for automatic login.');
|
||||
await notify('gog: no longer signed in and not enough options set for automatic login.');
|
||||
if (cfg.headless) {
|
||||
console.log('Run `SHOW=1 node gog` to login in the opened browser.');
|
||||
await context.close();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ try {
|
|||
const error = await page.locator('.a-alert-content').first().innerText();
|
||||
if (!error.trim.length) return;
|
||||
console.error('Login error:', error);
|
||||
notify(`prime-gaming: login: ${error}`);
|
||||
await notify(`prime-gaming: login: ${error}`);
|
||||
await context.close(); // finishes potential recording
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
@ -68,7 +68,7 @@ try {
|
|||
}).catch(_ => { });
|
||||
} else {
|
||||
console.log('Waiting for you to login in the browser.');
|
||||
notify('prime-gaming: no longer signed in and not enough options set for automatic login.');
|
||||
await notify('prime-gaming: no longer signed in and not enough options set for automatic login.');
|
||||
if (cfg.headless) {
|
||||
console.log('Run `SHOW=1 node prime-gaming` to login in the opened browser.');
|
||||
await context.close(); // finishes potential recording
|
||||
|
|
|
|||
9
util.js
9
util.js
|
|
@ -99,8 +99,8 @@ export const prompt = o => enquirer.prompt({name: 'name', type: 'input', message
|
|||
import { exec } from 'child_process';
|
||||
import { cfg } from './config.js';
|
||||
|
||||
export const notify = (html) => {
|
||||
if (!cfg.notify) return;
|
||||
export const notify = (html) => new Promise((resolve, reject) => {
|
||||
if (!cfg.notify) return resolve();
|
||||
const title = cfg.notify_title ? `-t ${cfg.notify_title}` : '';
|
||||
exec(`apprise ${cfg.notify} -i html ${title} -b '${html}'`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
|
|
@ -108,12 +108,13 @@ export const notify = (html) => {
|
|||
if (error.message.includes('command not found')) {
|
||||
console.info('Run `pip install apprise`. See https://github.com/vogler/free-games-claimer#notifications');
|
||||
}
|
||||
return;
|
||||
return resolve();
|
||||
}
|
||||
if (stderr) console.error(`stderr: ${stderr}`);
|
||||
if (stdout) console.log(`stdout: ${stdout}`);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const escapeHtml = (unsafe) => unsafe.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll("'", ''');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue