♻️ refactor(epic-claimer): enhance screenshot path resolution
Some checks failed
build-and-push / lint (push) Successful in 7s
build-and-push / sonar (push) Failing after 0s
build-and-push / docker (push) Has been skipped

- improve screenshot path by using path.resolve for better cross-platform compatibility
- organize screenshots into a structured directory hierarchy
This commit is contained in:
nocci 2026-01-08 15:27:19 +00:00
parent fd0fc4e981
commit af90aa7c42

View file

@ -15,6 +15,7 @@ import {
} from './src/util.js';
import { cfg } from './src/config.js';
const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games';
const COOKIES_PATH = path.resolve(cfg.dir.browser, 'epic-cookies.json');
const BEARER_TOKEN_NAME = 'EPIC_BEARER_TOKEN';
@ -292,8 +293,8 @@ const claimGame = async (page, game) => {
notify_game.status = 'claimed';
} catch (e) {
notify_game.status = 'failed';
const p = screenshot('failed', `${game.offerId || game.pageSlug}_${filenamify(datetime())}.png`);
await page.screenshot({ path: p, fullPage: true }).catch(() => { });
const screenshotPath = path.resolve(cfg.dir.screenshots, 'epic-games', 'failed', `${game.offerId || game.pageSlug}_${filenamify(datetime())}.png`);
await page.screenshot({ path: screenshotPath, fullPage: true }).catch(() => { });
console.error(' Failed to claim:', e.message);
}
@ -378,3 +379,4 @@ export const claimEpicGamesNew = async () => {
};
export default claimEpicGamesNew;