exitCode should be 130 instead of 1 on SIGINT
https://unix.stackexchange.com/questions/386836/why-is-doing-an-exit-130-is-not-the-same-as-dying-of-sigint
This commit is contained in:
parent
21ed2794f4
commit
38c5402df0
4 changed files with 16 additions and 24 deletions
|
|
@ -2,7 +2,7 @@ import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdate
|
|||
import { authenticator } from 'otplib';
|
||||
import path from 'path';
|
||||
import { existsSync, writeFileSync } from 'fs';
|
||||
import { jsonDb, datetime, stealth, filenamify, prompt, notify, html_game_list } from './util.js';
|
||||
import { jsonDb, datetime, stealth, filenamify, prompt, notify, html_game_list, handleSIGINT } from './util.js';
|
||||
import { cfg } from './config.js';
|
||||
|
||||
const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games';
|
||||
|
|
@ -13,11 +13,7 @@ console.log(datetime(), 'started checking epic-games');
|
|||
const db = await jsonDb('epic-games.json');
|
||||
db.data ||= {};
|
||||
|
||||
let exit = false;
|
||||
process.on('SIGINT', () => { // e.g. when killed by Ctrl-C
|
||||
console.log('\nInterrupted by SIGINT. Exit! Exception shows where the script was:\n');
|
||||
exit = true;
|
||||
});
|
||||
handleSIGINT();
|
||||
|
||||
// https://www.nopecha.com extension source from https://github.com/NopeCHA/NopeCHA/releases/tag/0.1.16
|
||||
// const ext = path.resolve('nopecha'); // used in Chromium, currently not needed in Firefox
|
||||
|
|
@ -193,8 +189,8 @@ try {
|
|||
}
|
||||
} catch (error) {
|
||||
console.error(error); // .toString()?
|
||||
process.exitCode = 1;
|
||||
if (error.message && !exit)
|
||||
process.exitCode ||= 1;
|
||||
if (error.message && process.exitCode != 130)
|
||||
notify(`epic-games failed: ${error.message.split('\n')[0]}`);
|
||||
} finally {
|
||||
await db.write(); // write out json db
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue